难道Android的支持JDBCAndroid、JDBC

2023-09-12 00:33:46 作者:暖男不暖心i

我知道,在Android上有android.database.sqlite包,提供有用的类来管理内部的android数据库。

I know that on Android there is android.database.sqlite package that provides helpful classes to manage the internal android database.

现在的问题是 - 我可以使用标准的java.sql包操纵Android的数据库,而无需使用来自android.database.sqlite东西*我尝试使用SQLite JDBC驱动程序来打开连接,但是当我添加库为e参考该项目的Eclipse崩溃与Java堆内存不足...无法转换成Dalvik虚拟机。

The question is - can I use the standard java.sql package to manipulate Android's database without using anything from android.database.sqlite.* I try to open connection using SQLite JDBC driver but when i added the library as e reference to the project eclipse crashes with "java heap out of memory ... couldn't convert to dalvik VM".

推荐答案

您无法轻松地导入一个JAR实施的java。* 类。而且,JDBC需要被移植到Android,因为它可能是依赖于类的JavaSE的Andr​​oid的缺乏。而且,你需要编写自己的JDBC驱动程序的SQLite反正包装的Andr​​oid的API已经提供了,因为我怀疑现有的JDBC驱动程序使用JNI。而且,当这一切完成后,你将有增加了很多臃肿的应用程序,这使得它的人会下载并保留您的应用程序。

You cannot import a JAR implementing java.* classes easily. And, JDBC would need to be ported to Android, since it probably relies upon classes in JavaSE that Android lacks. And, you would need to write your own JDBC driver for SQLite anyway, wrapping the API Android already supplies, since I suspect the existing JDBC driver uses JNI. And, when all of that is done, you will have an application that adds a lot of bloat, making it less likely people will download and retain your application.

总之,我不会走这条路。

In short, I wouldn't go this route.