Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java7 can not find com/microsoft/sqlserver/jdbc/SQLServerDataSource  RSS feed

 
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
upgrading from  java1.5 to java7  and from sqlserver jdbc 4 to 6.

I altered my CLASSPATH to point to the sqljdbc41.jar  found in the jre7 directory of sqljdbc_6.0 from the sqljdbc_6.0.8112.200_enu.tar
I have change dmy javac to use  /opt/java7/bin/javac 

I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/sqlserver/jdbc/SQLServerDataSource

However,
I know the class is there because if I try to compile with java6, it gives me this:
warning: com/microsoft/sqlserver/jdbc/SQLServerDataSource.class(com/microsoft/sqlserver/jdbc:SQLServerDataSource.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.

Then I compile with java7, it compiles without warning.
But when I run the code it gives the NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/sqlserver/jdbc/SQLServerDataSource
        at testms.main(testms.java:31)
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDataSource
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

I have also tried mssql-jdbc-6.2.2.jre7.jar  found in sqljdbc_6.2.2.1_enu.tar

I have verified that my CLASSPATH does include the needed jar, and includes only ONE mssql jar at the time I compile.

I am running this on hpux itanium 11

 
Sheriff
Posts: 4960
136
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you verified that the class com/microsoft/sqlserver/jdbc/SQLServerDataSource is in the jar file?  Jars or just tar (or Zip?) files and can be looked at and searched.

Barring that, could you post the complete stack trace, or was this it?  I'm looking for the line in your program that received this error.

 
eileen keeney
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have verified that class com/microsoft/sqlserver/jdbc/SQLServerDataSource is in the jar file.  Note the warning message I get when using Java6 instead of Java7.  It specifically mentions this library as being a version that should be compiled with an upgraded compiler.  Since I do not get the warning using java7, I conclude that java7 is a compatible compiler with the library.
I also see this library listed when using jar -tf.

The code I am using, for this test, is almost exactly what is in the Example that comes with the library. 
The code line is:
SQLServerDataSource ds = new SQLServerDataSource();



Output:


 
eileen keeney
Ranch Hand
Posts: 56
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my problem.

I went back to the MS site and downloaded another copy of the driver, and that seems to have fixed the issue.

Thank you for looking at my question and trying to help me.
 
author & internet detective
Marshal
Posts: 38366
645
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a cow for posting the solution. I was reading this thread baffled because what you described shouldn't be a possible. A corrupt jar would do it though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!