Android 是否支持 JDBC [英] Does Android Support JDBC

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

问题描述

我知道在 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 VM"而崩溃.

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".

推荐答案

您无法轻松导入实现 java.* 类的 JAR.而且,JDBC 需要移植到 Android,因为它可能依赖于 Android 缺少的 JavaSE 中的类.而且,无论如何您都需要为 SQLite 编写自己的 JDBC 驱动程序,包装 Android 已经提供的 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.

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

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