PLEASE HELLP!!!! Hi guys, I am almost crazy with this problem. THANK YOU!
I am doing a little and simple program to connect from Microsoft Visual j# .NET java program to an Access database. I am getting this error:
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver at com.ms.vjsharp.lang.VJSClassLoader.loadClass(String name, Boolean resolve) at com.ms.vjsharp.lang.VJSClassLoader.__getClassFromClassLoader(VJSClassLoader ld, String className) at com.ms.vjsharp.lang.VJSClassLoader.loadClass(String name) at java.lang.Class.forName(String className, Assembly callerA) at java.lang.Class.forName(String className) at ConnectProject.Connect.getConnection() in F:\Vigo\ConnectProject\ConnectProject\Connect.jsl:line 30 Error Trace in getConnection() : sun.jdbc.odbc.JdbcOdbcDriver
I have tried different forums and read a lot on internet, I set my CLASSPATH in this way:
CLASSPATH=C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;c:\j2sdk1.4.2_12\bin\rt.jar
I checked the files msbase.jar, msutil.jar and mssqlserver.jar exist in the directory. Also, the rt.jar is in c:\j2sdk1.4.2_12\bin\rt.jar.
Please somebody help me, I am being stuck here for 2 weeks.
Here is the code I am using:
package ConnectProject;
import java.*; public class Connect { private java.sql.Connection con = null; private final String url = "jdbc:microsoft:sqlserver://"; private final String serverName= "localhost"; private final String portNumber = "1433"; private final String databaseName= "pubs"; private final String userName = "user"; private final String password = "password"; // Informs the driver to use server a side-cursor, // which permits more than one active statement // on a connection. private final String selectMethod = "cursor";
It looks like a classical classpath problem. Your code looks good, I'm sure you can execute it from the compiler, right? Try to print out your classpath variable during runtime (System.Properties ...)
Since I always set the classpath at program start I can't tell you if you have to put a '"' symbol at the start and the end of the classpath variable or to bring all entries to the 8.3 format.
one more thing. When posting code here, please use the java tags as shown on the right side in the "formatting your post" section. But: do NOT copy your old unformatted code into it but copy the code directly from your compiler.