|
|
|
|
|
|
|
|
|
Changing the JDBC Driver |
|
|
|
If you want to change or set the JDBC driver, your first need to collect some information from the documentation from the database manufacturer and from your DBA. The first is the Java class name of the JDBC driver. The second is the format of the JDBC URL. These can be obtained from your database's documentation. Next you will most likely need the hostname, database id, etc. from your DBA. These values you will insert in the specified places in the JDBC URL. JDBC Driver Name. The JDBC driver name is the name of the Java class that implements the driver. Some examples are:
JDBC URL. The URL specifies information such as the protocol to be used, database id, host name where the database server is running, etc. For example, the URL for the JDBC-ODBC driver supplied with Java is jdbc:odbc:dsn where dsn is the data source name specified in Windows ODBC Data Source Administrator (double-click on ODBC in the Control Panel) for the ODBC data source you are using. If your documentation says something like "open a connection to the database named, mydatabase, with the JDBC getConnection method":
Take everything inside the first quoted string, Another Oracle example using their thin driver which is a Type IV driver that doesn't require Oracle Client to be installed on each client. The Oracle Thin driver will download all of the classes it needs and allow the Java client to talk straight to the database server located on the web server:
Take everything inside the first quoted string, Changing the generated Java code. There are few different API calls that are used in the generated Java code to setup the JDBC driver name and URL. The following is a common one:
After the Java code is generated, you can change these lines to reflect the values you want to use. Change the first line above with the JDBC driver name. Change the second line with the JDBC URL as the first argument and the user id and password as the remaining arguments. For example if you moved your data to Oracle and serv12 is the host name and dmvdb is the database id then the lines would be:
Note: another common API you might find in the generated Java code is:
The setConnectionString call has the same arguments as the Connection.Open function call decribed above. A less commonly used API is:
The first three arguments are the same as the arguments as the Connection.Open function call decribed above. The fourth argument is the JDBC driver name. |
|
|
|
|
|
|