Project

Profile

Help

JDBC / saxon connection problems

Added by Anonymous about 17 years ago

Legacy ID: #4619794 Legacy Poster: sascha mantscheff (smantscheff)

I'm trying to use the saxon sql extension with the jdbc/mysql adapter. I can establish a connection to my database server with a test program. This contains the statements: Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://mysite/mydb", "user", "password"); (with all the literal strings replaced by real connection parameter strings). This connection opens and I can retrieve data from the database. Now I tried to run a simple XSL which connects with the same parameters to the database. This fails with a JDBC connection failure. I extracted saxon9-sql.jar and inserted some debug output in SQLConnect.java. This shows that SQLConnect.java gets the correct parameters from the XSL sheet. The connection statement in SQLConnect.java reads try { Class.forName(dbDriverString); connection = DriverManager.getConnection(dbString, userString, pwdString); } catch (Exception ex) { System.out.println( "dbDriverString: " + dbDriverString + "\ndbString: " + dbString + "\nuserString " + userString + "\npwdString: " + pwdString); dynamicError("JDBC Connection Failure: " + ex.getMessage(), SaxonErrorCode.SXSQ0003, context); } This code always leads to an exception at the statement connection=... But the output shows the same connection parameters as the working code. I'm stuck. Any ideas are welcome.


Replies (2)

RE: JDBC / saxon connection problems - Added by Anonymous about 17 years ago

Legacy ID: #4619843 Legacy Poster: Michael Kay (mhkay)

I'm afraid there's very little I can do to help with this. I could ask you what the actual JDBC connection failure was - someone might understand the message, but I doubt that I would. Are you sure there aren't some stray characters in there like quote signs that might be confusing your diagnostics? Are you sure the Class.forName() is succeeding - a classpath difference between your Saxon environment and your freestanding environment could make a difference.

RE: JDBC / saxon connection problems - Added by Anonymous about 17 years ago

Legacy ID: #4620598 Legacy Poster: sascha mantscheff (smantscheff)

OK, this is obviously a classpath issue. I replaced the unspecific exceptions in SQLConnect.java by the more specific ClassNotFoundException and SQLException. The ClassNotFoundException was thrown by Class.forName. I found a little tool named JWhich which helped me to locate the com.mysql.jdbc.Driver in a jar, and adding this jar to the -classpath runtime parameter solved the problem. Thanks for your hints.

    (1-2/2)

    Please register to reply