Wrote a Java program in Notepad, connected to SQL Server 2008, downloaded the Microsoft JDBC from the Internet (address: http://msdn.microsoft.com/zh-cn/data/ aa937724.aspx), compile no problem, the execution of the time will be reported error: Java.lang.ClassNotFoundException: Com.microsoft.jdbc.sqlserver.SQLServerDriver the solution, the JDBC package has been placed in the source directory AH?! Later, the JDBC package is placed in the JRE related directory Jre\lib\ext, it is possible.
PS. You can compile without the need for the JDBC driver package, as long as the runtime can find the driver package under Jre\lib\ext. Another: Microsoft's JDBA drive contains a low version and a high version, if it is connected to SQL2008, it is best to remove the lower version of the JDBC, because the runtime may catch the lower version of the Jdbc**.jar.
Attach the steps for writing a Java program in Notepad:
1. Install the JDK. Open cmd after installation, execute Java and Javac successfully
2, create a program with Notepad and save it as a Java file. Note that the class name must match the file name, and Java is case-sensitive
3,cmd window, switch to this directory, compile with Javac Xxxxx.java. Add-classpath parameters when necessary
4. Place the necessary jar packages under the Jre\lib\ext
5, execute Java program with Java xxxxx
On the treatment of Java.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver