|
|||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
SQLite |
This is a Java wrapper including a basic JDBC driver for the SQLite 2/3 database engine. It is designed using JNI to interface to the SQLite API. That API is wrapped by methods in the SQLite.Database class. Since June, 2002, it includes a small JDBC driver, which allows the most basic things to be carried out using the java.sql package. Since September, 2004, SQLite3 (minimum 3.0.7) is supported which is rather experimental. The JNI part can be generated to include support for both SQLite 2.x and 3.x and detects at runtime the type of the database. Support for SQLite3 has been tested on Linux only.
The current source tarball can be downloaded from javasqlite-20040919.tar.gz. It has been tested on Linux, using SQLite 2.8.14 and above with ISO8859-1 encoding, and the JDK 1.1.8 version 3 from Blackdown, the JDK 1.3 from IBM, and the JDK 1.4.2 from Sun. For rebuilding the following requirements must be met:
$ ./configure ... $ make ... $ su -c "make install" ...
To override the directory where configure looks for SQLite and JDK the configure options --with-sqlite=DIR, --with-sqlite3=DIR, and --with-jdk=DIR can be used. To specify the place where the native library (the libsqlite_jni.so file) shall be installed, use the --prefix=DIR option. The default place is /usr/local/lib, i.e. the prefix defaults to /usr/local. To specify where the sqlite.jar file containing the high-level part and the JDBC driver shall be installed, use the --with-jardir=DIR option. The default is /usr/local/share/java. At runtime, it is necessary to tell the JVM both places with the -classpath and -Djava.library.path=.. command line options.
For Win32 (NT4 or above) a makefile javasqlite.mak is provided in the source archive. That makefile contains some build instructions and uses the J2SE 1.4.2 from Sun and MS Visual C++ 6.0. A DLL with the native JNI part (including SQLite 2.8.13) and the JAR file with the Java part can be downloaded from javasqlite-20040424-win32.zip.
After successful build and installation a small test program can be run by invoking the following commands:
$ make test ... $ java -classpath ... -Djava.library.path=... test version: 2.5.0 ==== local callback ==== #cols = 5 col0: type col1: name ...
A simple shell modelled after that of SQLite can be invoked as
$ java SQLite.Shell [options] database [sql string]or using the JAR file
$ java -jar sqlite.jar [options] database [sql string]
The native part of the Java SQLite wrapper takes the compile-time character encoding of the SQLite engine into account, and tries to map the Java unicode string representation into the system encoding and vice versa when SQLite has not been built with UTF-8 support. This can be overriden programatically or by specifying the -DSQLite.encoding=x command line option to the Java runtime, where x must be a charset name recognized by your Java environment. If the SQLite engine supports UTF-8, no special options are needed.
If you like to try the JDBC driver, use SQLite.JDBCDriver
as the JDBC drivers's class name. Make sure that you have the
sqlite.jar in your class path and the native
library in your java library path. The JDBC URLs to connect to
an SQLite database have the format jdbc:sqlite:/path,
where path has to be specified as the path
name to the SQLite database, for example
jdbc:sqlite://dirA/dirB/dbfile
jdbc:sqlite:/DRIVE:/dirA/dirB/dbfile
jdbc:sqlite:///COMPUTERNAME/shareA/dirB/dbfile
For now, the only data types
supported on SQLite tables are java.lang.String,
short, int, float, and double.
This depends mostly on the availability of the PRAGMAs
show_datatypes and table_info.
Most basic database meta data methods are implemented,
thus enough information is available to access SQLite
databases with JDK >= 1.3 and the
ISQLViewer
tool.
Other useful information to make this package work on ARM Linux can be found in How To compile SQLite with JDBC for the iPAQ.
This software and accompanying documentation is released under a BSD-style license:
This software is copyrighted by Christian Werner |
|
|||||||
PREV NEXT | FRAMES NO FRAMES |