Android中使用JDBCAndroid、JDBC

2023-09-04 12:40:22 作者:好姑娘俄妈造

所有的教程,我所遇到的从机器人连接到外部数据库,其中大部分的服务器上使用的PHP程序,并使用一个httppost来传递参数中。你为什么不使用JDBC的人只需要直接连接到数据库。或者是有,我很想念这里的某个点。

Of all the tutorials i have come across to connect to an external database from android, most of them use php program on the server and use a httppost to pass the arguments. Why dont people just connect directly to the database using jdbc . Or is there some other point that i am missing here.

推荐答案

在移动世界里没有什么完美的接待让您得到掉线和丢失的数据时,进出良好的接收用户移动。 JDBC的协议是不是设计来处理发生在移动,尤其是当你在查询中间的完整/部分断开。 HTTP在另一方面,至少可以让你来设计自己的重试机制作为一个失败的HTTP请求仅仅是一个失败的HTTP请求,而不是例外,从网络层/ JDBC驱动程序冒泡了。

In the mobile world there no such thing as perfect reception so you get dropped calls and missing data when the user moves in and out of good reception. The JDBC protocol isn't designed to handle the complete/partial disconnect that occurs in mobile, especially when you are in the middle of a query. HTTP on the other hand at least allows you to design in your own retry mechanism as a failed HTTP request is just a failed HTTP request and not an exception bubbling up from the network layer/JDBC driver.

另外,作为您的通信通过公共互联网(即使是通过SSL)进入你的服务器中的数据应该至少以某种方式来检查之前,访问数据库。

Also as you are communicating over the public internet (even over SSL) the data going into your server should at least be checked in some manner before it hits the database.