Cagen DBF JDBC Driver v4.2 Documentation
Setting the CLASSPATH
To put dbfdriver.jar into your class path, you should use "export CLASSPATH=/usr/share/lib/dbfdriver.jar:$CLASSPATH" on Solaris and Linux, and "SET CLASSPATH=\javalib\dbfdriver.jar;%classpath%" on Windows.
Loading the Driver
Any source that uses JDBC needs to import the java.sql package by using "
Caigen DBF driver' name is com.caigen.sql.dbf.DBFDriver, and you can uses it without
involving hard coding the driver into your code. You do this by setting the
jdbc.drivers system property. For example, for command line apps you can use:
java -Djdbc.drivers=com.caigen.sql.dbf.DBFDriver yourApp
Then, the JVM upon startup will load the drivers automatically. Some applications (JBoss, Tomcat etc) support a .properties file which they use to save putting this on the command line.
The second method is the most common and involves you loading the driver yourself.
From then on you can get connections from DriverManager.
Note: If Class.forName() throws ClassNotFoundException, you should check your classpath.
Data Source class is com.caigen.sql.CaigenDataSource, and Connection Pool Data Source class is com.caigen.sql.CaigenConnectionPoolDataSource.
Connecting to the Database
After the driver has been registered with the DriverManager, you can obtain a Connection instance that is connected to a particular database by calling DriverManager.getConnection(). With JDBC, a database is represented by a URL (Uniform Resource Locator).
Embedded: jdbc:dbf:[//]/[DatabasePath][?prop1=value1[;prop2=value2]] (You can omit that "//" characters sometimes) For example: "jdbc:dbf:/." "jdbc:dbf:/c:/data" for Windows driver "jdbc:dbf:///c:/data" for Windows driver "jdbc:dbf:////usr/data" for unix or linux "jdbc:dbf://///192.168.10.2/sharedir" for UNC path "jdbc:dbf:/./data" Compressed Database:(.ZIP, .JAR, .GZ, .TAR, .BZ2, .TGZ, .TAR.GZ, .TAR.BZ2) jdbc url format is the same as embedded url and remote url. For example: "jdbc:dbf:/c:/test/testdbf.zip Memory-only Database: jdbc:dbf:/_memory_/ URL Database:(http protocol, https protocol, ftp protocol) jdbc:dbf:http://httpURL jdbc:dbf:https://httpsURL jdbc:dbf:ftp://ftpURL For example: "jdbc:dbf:http://www.caigen.com/test" //Note: FTP site's user/password should be set in ftpURL, and cannot be set in JDBC connection property because user/password JDBC connection property belongs to server/client connection. SAMBA Database:(smb protocol) jdbc:dbf:smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?[param=value]] For example: "jdbc:dbf:smb://test1:firstname.lastname@example.org/dbffiles/zone" //Note: SAMBA user/password should be set in SMB url, and cannot be set in JDBC connection property because user/password JDBC connection property belongs to server/client connection. UNC path JDBC url: jdbc:dbf:/uncpath jdbc:dbf:///uncpath For example: "jdbc:dbf:/\\PC17\c$\values" "jdbc:dbf:/\\PC17\val" Free JDBC url:(Warning: only use it for special project) jdbc:dbf:/" or "jdbc:dbf:///". Then you can use some full UNC path names in SQL to visit anywhere where your Java VM has right to access. For instance: select * from \\amd2500\e$\dbffiles\test; elect * from "\\amd2500\d$\dbfiles".test; select * from ".".test; Caigen DBF supports seamlessly data mining on memory-only table, physical table, url table, compressed table, SAMBA table in a sql.
To connect, you need to get a Connection instance from JDBC. To do this, you use the DriverManager.getConnection() method:
Connection con = DriverManager.getConnection(url, properties);
There are a few different signatures for the getConnection() method. You should see the API documentation that comes with your JDK for more specific information on how to use them. You can specify additional properties to the JDBC driver by placing them in a java.util.Properties instance and passing that instance to the DriverManager when you connect.
|user||The user to connect as||null|
|password||The password to use when connecting||null|
|charSet||To specify a Character Encoding Scheme other than the client default. You can find a Supported Encodings list of file:///c|/jdk1.2/docs/guide/internat/encoding.doc.html. Cp895(Czech MS - DOS 895), Cp620(Polish MS - DOS 620) and Mazovia are extra supported although JVM doesn't support those.||null|
|lockTimeout||To specify DBF driver's timeout in milliseconds to wait until other processes or Xbase applications released record lock or table lock. 0 means a default value, and <0 means no wait.||1000|
|tmpdir||Indicates whether set a temp directory, Default: the value of JVM's "java.io.tmpdir" property. If that value is incorrect, uing the directory of JDBC url. _memory_ means large data in memory.||null|
|delayedClose||Indicates the delayed seconds for close transaction. That option is used to avoid frequent close/open table operations for following sqls. Automatic temporary index is disabled when delayedClose<=60s. You can use 0~120 seconds. Default: 3.||null|
|maxCacheSize||Indicates the max memory utilization for per table on automatic temporary index or matched result cache. You can use 16~65536 kilo bytes. Default: 1024.||null|
|deletesAreVisible||Indicates whether DBF's resultSet includes deleted records.||false|
|DefaultExtension||Indicates whether DBF driver uses another default extension to replace 'DBF'.||DBF|
|OtherExtensions||Indicates whether DBF driver supports other extensions except for 'DBF'.||false|
|versionNumber||Xbase Version Number. You can use null, "30"(Visual FoxPro 3.0~9.0), "02"(FoxBase, dBASE II), "03"(dBASE III, Clipper), "83", "04"(dBASE IV), "05"(dBASE V), "F5"(FoxPro),"8B", "8E", "7B", or "DB2K"(dbase 2000). This parameter is only used for CREATE TABLE.||30|
|ODBCTrimBehavior||Indicates whether works like MS Access ODBC driver to ignore tail space characters in condition expression. You can use null, true, false||false|
|caseInsensitive||Indicates whether is case insensitve for string comparison. You can use null, true, false||false|
|emptyDecimalAsZero||Indicates whether returns empty decimal as zero value. You can use null, true, false||false|
|emptyStringAsNull||Indicates whether returns empty string as null value. You can use null, true, false||true|
|blockSize||Xbase's blockSize. You can use 1~255||64|
|missingMemoFile||Indicates the action when memo file is missing. You can use "throw" (throw an SQLException), "ignore" (continue to load table when memo file is missing. All memo columns will return null value.), and "repair" (clear all old memo value, and rebuild a new memo file).||throw|
When your code then tries to open a Connection, and you get a No driver available SQLException being thrown, this is probably caused by the driver not being in the class path, or the JDBC url not being correct.
To close the database connection, simply call the close() method to the Connection: