• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class.forName() not working  RSS feed

 
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When the program executes the line "Class.forName("org.h2.Driver");" it jumps to "resultSet.close();" without throwing an exception. I don't think the problem is with the H2 driver.

Your help will be greatly appreciated,

Alejandro Barrero
 
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a modern JDBC driver and are using at least Java 6, you don't need that line. In either case, make sure the driver is in your classpath.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That method can also throw a couple of Errors. Try catching Throwable instead of Exception and see if you get anything.
 
Alejandro Barrero
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joanne; shouldve thought of it. The exception is "java.lang.UnsupportedClassVersionError: org/h2/Driver : Unsupported major.minor version 51.0". it looks like the problem is the driver.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case you don't know a class version of 51 means the class was compiled with Java 7, so you either need to compile your code with Java 7 or you need a version of the driver for whichever version of Java you are using.
 
Alejandro Barrero
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I do have Java 7 version 51, but after I set it in MyEclipse I began to have the complain from the class loader even for a HelloWorld program. I am downloading Java again and will also try with Eclipse, although I need MyEclipse for Swing Matisse.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!