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

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

问题描述

我正在尝试使用 JDBC 驱动程序将我的 android 应用程序连接到服务器 (PostgreSQL),但出现此错误:

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.

每个人都可以帮助我吗?

Everybody can help me ?

推荐答案

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

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

不要尝试直接在 Android 设备上使用 JDBC.这样你会省去很多麻烦.我在JDBC vs Web Service for Android" 问题.

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.

在可通过网络访问的应用服务器上编写数据库逻辑,并通过 HTTP+JSON、SOAP、XML-RPC 或类似方式与该应用服务器通信.这将大大提高带宽效率,并且您可以使您的应用程序对连接问题的容忍度更高.它还使您不必将数据库服务器直接暴露给 Internet - 只要您使用 SSL,PostgreSQL 就不必担心,但最好根本不必这样做.

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.

在 JBoss AS 7、Tomcat 7 或类似版本上使用 JAX-RS,您应该能够非常轻松地为您的应用程序组合一个 Web RESTful XML/JSON 服务 API.人们似乎也很快将 REST/JSON API 与 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.

您可以轻松地使用几乎任何您喜欢的语言编写 JSON/REST Web API.只需搜索 REST server 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.

Kaw"在一个已删除的回答中指出,还有虚拟 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.

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

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