简体   繁体   English

如何从Android设备连接到SQL Server数据库

[英]How to connect to sql server database from android device

I want to build android app that can connect to sql server database using jtds jdbc. 我想构建可以使用jtds jdbc连接到sql server数据库的android应用。 When i try run the program at emulator with ip 10.0.2.2, it works fine. 当我尝试使用ip 10.0.2.2在模拟器上运行程序时,它工作正常。 But when i try build apk and install it to android device,i change the ip to 192.168.0.5 (my computer ip in LAN) and it doesnt work, Please help. 但是,当我尝试构建apk并将其安装到android设备时,我将ip更改为192.168.0.5(局域网中的我的计算机ip),它不起作用,请帮忙。

here is the code 这是代码

Please check whether your phone is also on the same network to which your computer is connected. 请检查您的手机是否也与计算机连接在同一网络上。

It is not a good idea to expose database directly to the client. 直接将数据库公开给客户端不是一个好主意。 instead you can have a web service in your computer which does database operations and you can call the web service from your android app. 相反,您可以在计算机中具有执行数据库操作的Web服务,并且可以从Android应用程序调用该Web服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM