File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JUnit & JDBC problem

 
Paul Ramsden
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Paul Ramsden
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which test runner are you using? I know people often have problems with the GUI version...
 
Paul Ramsden
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ANT is running in text mode, the JUnit task is too.
 
Barry Hawkins
ranger
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic