我正在使用以下代码在SQL
数据库上本地连接
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
String connString = "jdbc:jtds:sqlserver://127.0.0.1:1433/dbname";
conn = DriverManager.getConnection(connString,"user","pass");
Run Code Online (Sandbox Code Playgroud)
当我运行此应用程序时,它给了我Network error
。连接失败127.0...
我的防火墙已打开1433
并启用了SQL
配置TCP/IP
。我还必须做什么?
如果localhost
要从设备中引用a ,请使用http://10.0.2.2:8080/
代替http://127.0.0.1/
或http://localhost/
。
由于您的Android模拟器正在上运行,Virtual Machine(QEMU)
因此您无法连接到直接在PC上运行的服务器。
并且,如果您是从Physical android设备运行您的应用的,请从您的PC使用网络IP。例如 http://198.10.12.21:80/
...
还要确保您的设备和PC(您从中调用localhost)在同一网络中
归档时间: |
|
查看次数: |
2758 次 |
最近记录: |