This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am trying to test some classes which use JDBC connections. The first TestCase to run is able to get a connection for each test it runs, but all later TestCases exit with 'SQLException - No suitable driver'. The tests are being run in batch mode using ANT. I guess it has something to do with class loading. Perhaps a new class loader for each test? My test code run in 2 successive Junit tests reproduces the problem.
Does anyone have any ideas? Paul [ July 15, 2003: Message edited by: Paul Ramsden ]
Joined: Sep 22, 2000
I have found a way around the problem. I added fork="yes" to the junit task in ANT. In spite of that, I would be glad to hear from anyone with insight into class loading in Junit. Paul
I, too, am experiencing this problem, and setting fork="yes" in my <junit> task is what resolved the issue. I also happen to be using the IBM DB2 Connect JDBC Type 2 driver like you are in the code above. As you know, Type 2 drivers interface heavily with native code on the client. You may find that the "net" driver for DB2 (Type 4, IIRC) works without the fork setting on the <junit> task, as it does not interface with native code libraries. The issue appears to be related to Apache Bug Report #19275: <junit> fails when test classes load native code. Hope this helps some other folks.
Barry Hawkins<br />All Things Computed<br />site: <a href="http://www.alltc.com" target="_blank" rel="nofollow"><br />weblog: [URL=http://www.yepthatsme.com]www.yepthatsme.com</a>