【发布时间】:2016-01-05 05:51:36
【问题描述】:
我正在尝试将 dart 与数据库连接(可选,如 postgrelsql、mongodb)。我安装了 postgresql 并创建了 db、table 和 goto pubspec.yaml 然后添加依赖 postgresql 并运行 pub get。 然后我提到了库文件
import 'package:postgresql/postgresql.dart';
连接详情
var uri = 'postgres://postgres:root@localhost:5432/testdb';
connect(uri).then((conn) {
});
但我得到以下错误,我无法清楚地理解。请帮助我。
Stack Trace:
Uncaught Uncaught Error: Unsupported operation: Socket constructor
堆栈跟踪: 不支持的操作:套接字构造函数 在 dart.wrapException (http://localhost:8080/dbconnection.dart.js:2531:15) 在 null.Socket_connect (http://localhost:8080/dbconnection.dart.js:11612:13) 在 dart.Socket_connect [as call$2] (http://localhost:8080/dbconnection.dart.js:11614:14) 在 ConnectionImpl_connect_closure.dart.ConnectionImpl_connect_closure.call$0 (http://localhost:8080/dbconnection.dart.js:13515:28) 在 dart.Future_Future$sync (http://localhost:8080/dbconnection.dart.js:4723:28) 在 dart.ConnectionImpl.static.ConnectionImpl_connect (http://localhost:8080/dbconnection.dart.js:13468:18) 在 dart.connect (http://localhost:8080/dbconnection.dart.js:12861:14) 在 dart.PostgrelSqlconn (http://localhost:8080/dbconnection.dart.js:12836:7) 在主要 (http://localhost:8080/dbconnection.dart.js:12825:15) 在 _wrapJsFunctionForAsync_closure.dart._wrapJsFunctionForAsync [as _captured_protected_1] (http://localhost:8080/dbconnection.dart.js:2923:11) (http://localhost:8080/dbconnection.dart.js:2531)
【问题讨论】:
标签: postgresql dart database-connection