Cagen Access JDBC Driver v4.0 Documentation

Index:

  1. Setting the CLASSPATH
  2. Loading the Driver
  3. Connecting to the Database
  4. Supported SQL Syntax
  5. Supported SQL Function

Setting the CLASSPATH

To put accessdriver.jar into your class path, you should use "export CLASSPATH=/usr/share/lib/accessdriver.jar:$CLASSPATH" on Solaris and Linux, and "SET CLASSPATH=\javalib\accessdriver.jar;%classpath%" on Windows.

Loading the Driver

Any source that uses JDBC needs to import the java.sql package by using " import java.sql.*;".

Caigen Access driver' name is com.caigen.sql.access.AccessDriver, 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.access.AccessDriver 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. It's simple:
Class.forName("com.caigen.sql.access.AccessDriver");
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:access:[//]/[DatabasePath][?prop1=value1[;prop2=value2]] (You can omit that "//" characters sometimes)
                        For example:
                                "jdbc:access:/."
                                "jdbc:access:/c:/data" for Windows driver
                                "jdbc:access:///c:/data" for Windows driver
                                "jdbc:access:////usr/data" for unix or linux
                                "jdbc:access://///192.168.10.2/sharedir" for UNC path
                                "jdbc:access:/./data"
                                "jdbc:access:/./data/mydata.mdb"
        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:access:/c:/test/testaccess.zip
        Memory-only Database:
                jdbc:access:/_memory_/
        URL Database:(http protocol, https protocol, ftp protocol)
                jdbc:access:http://httpURL
                jdbc:access:https://httpsURL
                jdbc:access:ftp://ftpURL
                        For example:
                                "jdbc:access: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:access:smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?[param=value]]
                        For example:
                                "jdbc:access:smb://test1:123@100.100.13.94/accessfiles/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:access:/uncpath
                jdbc:access:///uncpath
                        For example:
                                "jdbc:access:/\\PC17\c$\values" 
                                "jdbc:access:/\\PC17\val"
	Free JDBC url:(Warning: only use it for special project)
                jdbc:access:/" or "jdbc:access:///". 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$\accessfiles\test;
                                elect * from "\\amd2500\d$\accessiles".test;
                                select * from ".".test;

         Caigen Access 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.

Property Name
Definition
Default Value
user The user to connect as null
password The password to use when connecting null
lockTimeout To specify Access driver's timeout in milliseconds to wait until other processes or Access 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. 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
versionNumber Access JET Version Number. You can use null, "JET3"(JET version 3.0), "JET4" (JET version 4.0), "JET5" (JET version 5.0).. This parameter is only used for CREATE DATABASE . JET4
ODBCTrimBehavior Indicates whether works like MS Access ODBC driver to ignore tail space characters in condition expression. You can use null, true, false true
caseInsensitive Indicates whether works like MS Access ODBC driver to be case insensitve for string comparison. You can use null, true, false false
otherExtension Indicates whether Access driver supports other extension beside 'MDB', 'MDE', 'ACCDB', 'ACCDE', and 'ACCDR'. You can use comma to assign more than one extension, for instance, otherExtension=DB,ACR . null
dateFormat dateFormat is used to specify a default parse sequence of date(Default: 'yyyy-MM-dd') format. Date and Time patterns follow the Java java.text.SimpleDateFormat Format (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) standard. yyyy-MM-dd
timeFormat timeFormat is used to specify a default parse sequence of time(Default: 'hh:mm:ss') format. Date and Time patterns follow the Java java.text.SimpleDateFormat Format (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) standard. hh:mm:ss
timestampFormat timestampFormat is used to specify a default parse sequence of timestamp(Default: 'yyyy-MM-dd hh:mm:ss') format. Date and Time patterns follow the Java java.text.SimpleDateFormat Format (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) standard. yyyy-MM-dd hh:mm:ss

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:

con.close();

 

Copyright © 2008-2019 Caigen Software. | All Rights Reserved. |