• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Unable to load JdbcOdbc library". Help please?!

 
Rich Unruh
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting an SQLException while doing a java.sql.DriverManager.getConnection. The error message is "Unable to load JdbcOdbc library".
I'm using JDK 1.2.2_07 under Solaris 2.8.
Any help or input would be _greatly_ appreciated.
CLASSPATH, Code, and output are shown below:
CLASSPATH=.:/usr/xmldbms/samples:/usr/xmldbms/xmldbms.jar:/usr/xerces-1_3_0/xerces.jar:/usr/Solaris_JDK_1.2.2_07/bin:/usr/Solaris_JDK_1.2.2_07/lib/dt.jar:/usr/Solaris_JDK_1.2.2_07/ lib/tools.jar:
Here's the code:
=============================================
static void createStatements(Map map, String basename)
throws Exception
{
FileOutputStream sqlFile;
String[] createStrings;
String url = "jdbcdbc:xmldbms",
driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Connection conn;
// Connect to the database and pass the JDBC Connection to the
// Map object. The Map object needs this to retrieve information
// about how to construct the CREATE TABLE statements.
java.sql.DriverManager.setLogStream(java.lang.System.out);
Class.forName(driver);
conn = DriverManager.getConnection(url);
=======================================

Here's the output:
========================================
JdbcOdbcDriver class loaded
DriverManager.initialize: jdbc.drivers = null
JDBC DriverManager initialized
registerDriver: driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@71ca06]
DriverManager.getConnection("jdbcdbc:xmldbms")
trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@71ca06]
*Driver.connect (jdbcdbc:xmldbms)
JDBC to ODBC Bridge: Checking security
No SecurityManager present, assuming trusted application/applet
JDBC to ODBC Bridge 1.2001
Current Date/Time: Mon May 14 14:41:04 GMT-05:00 2001
Loading JdbcOdbc library
Unable to load JdbcOdbc library
java.sql.SQLException: Unable to load JdbcOdbc library
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:82)
at sun.jdbc.odbc.JdbcOdbc.<init>(JdbcOdbc.java:88)
at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:315)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at GenerateMap.createStatements(Compiled Code)
at GenerateMap.generateMap(GenerateMap.java:99)
at GenerateMap.main(GenerateMap.java:72)
Unable to load JdbcOdbc library
Unable to allocate environment
getConnection: no suitable driver
java.sql.SQLException: No suitable driver
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:64)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at GenerateMap.createStatements(Compiled Code)
at GenerateMap.generateMap(GenerateMap.java:99)
at GenerateMap.main(GenerateMap.java:72)
SQLException: SQLState(08001)
java.sql.SQLException: No suitable driver
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:64)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at GenerateMap.createStatements(Compiled Code)
at GenerateMap.generateMap(GenerateMap.java:99)
at GenerateMap.main(GenerateMap.java:72)
======================================
 
kichu kichu
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
conn = DriverManager.getConnection(url);
In the COnnection given above,do'nt u have a username and password for the database i.e something like this--->
conn = DriverManager.getConnection(url,username,password);
regards,
kichu.
 
Rich Unruh
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kichu kichu:
Hai,
conn = DriverManager.getConnection(url);
In the COnnection given above,do'nt u have a username and password for the database i.e something like this--->
conn = DriverManager.getConnection(url,username,password);
regards,
kichu.

Thanks for the reply.
Late yesterday I finally figured it out.
Just in case there's anyone else out there with this problem, here's the explanation: The environment variable "LD_LIBRARY_PATH" that must contain a reference to the .../lib directory (or equivelent) for your driver. The Driver Manager uses LD_LIBRARY_PATH to search for libraries.
Regarding your suggestion: There are three variants of DriverManager.getConnection(), one of which passes only the URL. The security is handled elsewhere.
Thanks again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic