4. JDBC Drivers

4.1. Configuring JDBC drivers
4.2. Connecting through ODBC
4.3. Specifying a library directory
4.4. Popular JDBC drivers

4.1. Configuring JDBC drivers

Before you can connect to a DBMS you have to configure the JDBC driver to be used. The driver configuration is available in the connection dialog or through FileManage Drivers

The configuration of a specific driver requires at least two properties:

  • the driver's class name
  • the library ("JAR file") where to find the driver class

After you have selected the .jar file for a driver, SQL Workbench/J will scan the jar file looking for a JDBC driver. If only a single driver is found, the classname is automatically put into the entry field. If more than one class is found that is a driver implementation, you will be prompted to select one. In that case, please refer to the manual of your driver, to choose the correct one.

[Caution]

If you enter the class name of the driver manually, remember that it's case-sensitive. org.postgresql.driver is different to org.postgresql.Driver (note the capital D for Driver)

The name of the library has to contain the full path to the driver's jar file, so that SQL Workbench/J can find it. Some drivers are distributed in several jar files. In that case, select all necessary files in the file open dialog, or enter all the filenames separated by a semicolon (or a colon on Unix style operating systems). This is also true for drivers that require a license file that is contained in a jar file. In this case you have to include the license jar in the list of files. Basically this list defines the classpath for the classloader that is used to load and instantiate the driver.

If the driver accesses files through its classpath definition that are not contained in a jar library, you have to include that directory as part of the library definition (e.g: "c:\etc\TheDriver\jdbcDriver.jar;c:\etc\TheDriver"). The file selection dialog will not let you select a directory, so you have to add it manually to the library definition.

[Note]

SQL Workbench/J is not using the system CLASSPATH definition (i.e. environment variable) to load the driver classes. Changing the CLASSPATH environment variable to include your driver's library will not work. Using the -cp switch to add a driver to the classpath when starting the application through a batch file will also not work.

You do not need to specify a library for the JDBC-ODBC bridge, as the necessary drivers are already part of the Java runtime.

You can assign a sample URL to each driver, which will be put into the URL property of the profile, when the driver class is selected.

SQL Workbench/J comes with some sample URLs pre-configured. Some of these sample URLs use brackets to indicate a parameters that need to be replaced with the actual value for your connection: (servername) In this case the entire sequence including the brackets need to be replaced with the actual value.

4.2. Connecting through ODBC

To connect to a database using an ODBC driver, you must first setup an ODBC datasource with the tools of your operating system (e.g. the control panel in Windows®)

Once you have set up the ODBC datasource, select the ODBC Bridge as the driver in the connection dialog. The JDBC URL for the datasource connection then is jdbc:odbc:name_of_your_datasource.

If you named your ODBC datasource ProductDB, then the JDBC url for SQL Workbench/J would be jdbc:odbc:ProductDB

4.3. Specifying a library directory

When defining the location of the driver's .jar file, you can use the placeholder %LibDir% instead of the using the directory's name directly. This way your WbDrivers.xml is portable across installations. To specify the library directory, either set it in the workbench.settings file, or specify the directory using the -libdir switch when starting the application.

4.4. Popular JDBC drivers

Here is an overview of common JDBC drivers, and the classname that need to be used. SQL Workbench/J contains predefined JDBC drivers with sample URLs for connecting to the database.

Most drivers accept additional configuration parameters either in the URL or through the extended properties. Please consult the manual of your driver for more detailed information on these additional parameters.

DBMSDriver classLibrary name
PostgreSQLorg.postgresql.Driver
postgresql-8.4-701.jdbc4.jar (exact name depends on PostgreSQL version)
http://jdbc.postgresql.org
Firebird SQLorg.firebirdsql.jdbc.FBDriver
firebirdsql-full.jar
http://www.firebirdsql.org/
Oracleoracle.jdbc.OracleDriver
ojdbc6.jar
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
H2 Database Engineorg.h2.Driver
h2.jar
http://www.h2database.com
HSQLDBorg.hsqldb.jdbcDriver
hsqldb.jar
http://hsqldb.sourceforge.net
IBM DB2com.ibm.db2.jcc.DB2Driver
db2jcc4.jar
http://www-01.ibm.com/support/docview.wss?rs=4020&uid=swg21385217
IBM DB2 for iSeriescom.ibm.as400.access.AS400JDBCDriver
jt400.jar
http://www-01.ibm.com/software/data/db2/java/
Apache Derbyorg.apache.derby.jdbc.EmbeddedDriver
derby.jar
http://db.apache.org/derby/
Teradatacom.teradata.jdbc.TeraDriver
terajdbc4.jar
http://www.teradata.com/DownloadCenter/Forum158-1.aspx
Sybase SQL Anywherecom.sybase.jdbc3.jdbc.SybDriver
jconnect.jar
http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/jconnect
MySQLcom.mysql.jdbc.Driver
mysql-connector-java-5.1.5-bin.jar (exact name depends on version)
http://www.mysql.com
SQL Server 2000/2005 (Microsoft driver)com.microsoft.sqlserver.jdbc.SQLServerDriver
sqljdbc4.jar
http://www.microsoft.com/sqlserver/2005/en/us/java-database-connectivity.aspx
SQL Server (jTDS driver)net.sourceforge.jtds.jdbc.Driver
jtds.jar
http://jtds.sourceforge.net
ODBC Bridgesun.jdbc.odbc.JdbcOdbcDriver
Included in the JDK