Curious how this is different from built-in sqlite jdbc support

186 views
Skip to first unread message

Joe Droider

unread,
Apr 11, 2012, 2:15:14 PM4/11/12
to sqld...@googlegroups.com
I have been searching through Google/Stackoverflow and other links to find if Android java.sql package support sqlite database through JDBC. It does look like there is built-in support, but not documented. I am wondering what SQLDroid compliments that the built-in wrapper doesn't provide.
I have piece of code that runs on Windows/Linux using standard java.sql classes talking to database. I like to port the same code to android with minimal changes.
Are there any examples on how to use this library?

Thanks
Joe

Jim Redman

unread,
Apr 11, 2012, 2:40:28 PM4/11/12
to sqld...@googlegroups.com
Joe,

I can't comment on the Android built in JDBC support, except that, as
far as I know, it's still not officially documented and not officially
recommended for use.

SQLDroid uses the documented Android sqlite API to provide JDBC support.

The documentation for JDBC is a little sparse, what it really needs is
someone with a fresh eye to document it and perhaps provide some
examples (was that a subtle enough hint?).

The driver itself is easy enough to use.

The driver is "org.sqldroid.SQLDroidDriver"

The URL is:

jdbc:sqldroid:PATH_TO_DATABASEFILE

The PATH_TO_DATABASEFILE is generally:

getFilesDir().getAbsolutePath()/filename

or something similar in the folders owned by the app. So, for example
the URL may be:

jdbc:sqldroid:/data/data/com.ergotech.android.Scouting/files/MyDatabase

but can be any valid path that the app can read/write, so:

jdbc:sqldroid:/sdcard/AnotherDatabase

is valid.

The driver is a pass-through to the underlying sqlite interface provided
by Android so you can generally get a feel for what's expected by
looking at, say, the android.database.sqlite.SQLiteDatabase documentation.

We use the driver exactly as you describe - the user has a choice of
which database they want to use and the code then works against almost
any of them (Oracle, MySQL, SQLServer - JTDS and the MS JDBC driver,
sqlite, HSQLDB, DB2, etc. etc.).

I have to say that the sqlite jdbc driver for Java, rather than Android,
seems a little challenged in certain regards. It won't work with our
code and date/time data, even though all the other listed database do.
Blobs also don't seem to work - we ended up Base64 encoding photographs
and storing them as String when testing with the PC version.

SQLDroid certainly has some pieces that are not implemented, but
hopefully they are obscure enough that you won't be needing them.

Thanks for your interest and please let us know how you get on.

Jim

--
Jim Redman
(505) 662 5156 x85
http://www.ergotech.com

Joe Droider

unread,
Apr 11, 2012, 3:22:05 PM4/11/12
to sqld...@googlegroups.com
Thanks Jim for fast reply.
If I understand this correctly, the sqldroid is an android jar (i.e. Dalvik jar file) that one needs to add as dependency in their android project. Then the database code should be able to find this driver and everything falls in place. That is beautiful.

How is this code licensed?
Is it GPL, Apache 2 or BSD license?

Thanks
Joe

Jim Redman

unread,
Apr 11, 2012, 4:18:18 PM4/11/12
to sqld...@googlegroups.com
Joe,

On 04/11/2012 01:22 PM, Joe Droider wrote:
> Thanks Jim for fast reply.
> If I understand this correctly, the sqldroid is an android jar (i.e.
> Dalvik jar file) that one needs to add as dependency in their android
> project. Then the database code should be able to find this driver and
> everything falls in place. That is beautiful.

Basically yes. I think technically the downloaded jar is Java ByteCode.
You put it in the "libs" directory of your Android project (or
wherever your IDE wants you to put such things) and it gets Dalvikised
as part of the build process.

I haven't checked the downloaded jar, but the code works against 1.6+ of
Android. I build it with 2.3 and use it on 1.6-4.x.

> How is this code licensed?
> Is it GPL, Apache 2 or BSD license?

Eclipse Public License 1.0

http://www.eclipse.org/legal/epl-v10.html

There actually used to be some fairly minimal, and somewhat outdated
documentation at:

http://code.google.com/p/sqldroid/

but I don't know what happened to that. Is it somewhere on GitHub?

Jim

Reply all
Reply to author
Forward
0 new messages