Archives of the TeradataForum
Message Posted: Tue, 25 Feb 2003 @ 11:20:15 GMT
What about the JDBC-ODBC library? When Java complains about not being able to find some library, it happens usually because (a) it is not there (in the Java class path), or (b) Java has not been instructed to load the appropriate driver class. The latter is common when using JDBC, because every driver must be loaded on its own, so it is registered with the DriverManager and then JDBC classes resolve the url 'jdbc:odbc:' because it realizes the driver sun.jdbc.odbc.JdbcOdbcDriver has been registered to handle these kind of JDBC urls.
If your problem looks like (a), include the path in environment variable CLASSPATH. But this should not help much, because the JDBC-ODBC bridge is brought along with the Java 2 SDK. And if you can find the SDK, you can find the driver.
For (b), you use a piece of code like this: String drvName = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:odbc:teradata"; Class.forName(drvName); Connection con = DriverManager.getConnection(url, p);
Note. A simple import won't do it. For example, if you try this instead of the code above
import sun.jdbc.odbc.JdbcOdbcDriver; String url = "jdbc:odbc:teradata"; Connection con = DriverManager.getConnection(url, p);
it does not work. The issue is that the import clause does not force load, and only with load the driver is registered to handle 'jdbc:odbc:' urls. Of course, you can the method 'registerDriver', but it is not a good practice: you end up with hard-wired code (as presented above).
Hope this helps.
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|