JDBC驱动程序的PostgreSQL采用Android [英] Driver JDBC PostgreSQL with Android

查看:226
本文介绍了JDBC驱动程序的PostgreSQL采用Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的Andr​​oid应用程序连接到服务器(PostgreSQL的)与JDBC驱动程序,但我有此错误:

I'm trying to connect my android application to a server (PostgreSQL) with JDBC Driver, but i have this error :

java.lang.ClassNotFoundException: org.postgresql.Driver
...
Caused by: java.lang.NoClassDefFoundError: org/postgresql/Driver
... 12 more
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
...
java.sql.SQLException: No suitable driver

我试了很多东西,比如添加在路径驱动程序的地址,但没有工作。我跟着这个教程: http://appliedcoffeetechnology.tumblr.com/post/10657124340 并增加了驾驶员JDBC4(我也尝试了JDBC3),在构建路径。

I tried many things, like add the address of the driver in the Path, but nothing work. I followed this tutorial : http://appliedcoffeetechnology.tumblr.com/post/10657124340 and added the driver JDBC4 (i also tried the JDBC3), in the Build Path.

每个人都可以帮我吗?

推荐答案

虽然不是严格的回答你的问题,我有一个建议。

While not the strict answer to your question, I do have a suggestion.

不要试图直接在Android设备上使用JDBC。你可以节省很多麻烦的方式。 <一href="http://stackoverflow.com/questions/15853367/jdbc-vs-web-service-for-android/15853566#15853566">I更详细地写上了JDBC VS Web Service的Andr​​oid的问题。

Don't try to use JDBC on the Android device directly. You'll save a lot of hassle that way. I wrote about that in more detail on the "JDBC vs Web Service for Android" question.

写您的数据库逻辑通过Web访问的应用程序服务器上,并通过HTTP + JSON,SOAP,XML-RPC,或类似的交谈,该应用程序服务器。这将是一个很大的带宽效率,你可以让你的应用程序有更多的宽容与连接这样的问题。它也使您不必直接暴露你的数据库服务器的互联网 - 没有太大的PostgreSQL的一个担心,只要您使用SSL,但还是最好不要有做所有

Write your database logic on a web-accessible application server and talk to that application server via HTTP+JSON, SOAP, XML-RPC, or similar. This will be a lot more bandwidth efficient and you can make your app a lot more tolerant of issues with connectivity that way. It also saves you from having to expose your database server directly to the Internet - not much of a worry with PostgreSQL so long as you use SSL, but still better not to have to do at all.

使用JAX-RS在JBoss AS 7,Tomcat 7的或类似的,你应该能够把一个网页REST风格的XML / JSON API服务,为您的应用程序pretty的轻松。人们似乎也把REST / JSON API一起使用pretty的迅速用PHP。

Using JAX-RS on JBoss AS 7, Tomcat 7, or similar you should be able to put together a web RESTful XML/JSON services API for your app pretty easily. People also seem to put REST/JSON APIs together pretty quickly with PHP.

您可以写在pretty的一个JSON / REST的Web API的多,你想用不同程度的缓解任何语言。只要搜索 REST服务器yourlanguagename

You can write a JSON/REST web API in pretty much any language you like with varying degrees of ease. Just search for REST server yourlanguagename.

卡奥已经指出,在一个已删除的答案,也有虚拟的JDBC驱动程序,通过HTTP隧道请求。这些可适合于一些应用。

"Kaw" has pointed out in a deleted answer that there are also virtual JDBC drivers that tunnel requests over HTTP. These may be suitable for some applications.

这篇关于JDBC驱动程序的PostgreSQL采用Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆