SQLServer2000JDBCdriver use: com. microsoft. jdbc. sqlserver. SQLServerDriverSQLServer2005and2008JDBCdrive use: com. microsoft. sqlserver. jdbc. SQLServerDriver and URLprefix is changed from jdbc: microsoft: sqlserver: To jdbc: sqlserver:
SQL Server 2000 JDBC driver: "com. microsoft. jdbc. sqlserver. SQLServerDriver "SQL Server 2005 and 2008 JDBC drive:" com. microsoft. sqlserver. jdbc. SQLServerDriver "and the URL prefix is changed from" jdbc: microsoft: sqlserver: // "to" jdbc: sqlserver :/
SQL Server 2000 JDBC driver: "com. microsoft. jdbc. sqlserver. SQLServerDriver"
SQL Server 2005 and 2008 JDBC drive :"Com. microsoft. sqlserver. jdbc. SQLServerDriver"
In addition, the URL prefix is changed from "jdbc: microsoft: sqlserver: //""Jdbc: sqlserver ://.
From: http://blogs.msdn.com/jdbcteam/archive/2007/06/15/java-lang-classnotfoundexception-com-microsoft-jdbc-sqlserver-sqlserverdriver.aspx
The following is an example that has been encapsulated into a function:
Public static Connection linktoSQLServer () {// String connect to SQL server String strServerIPAddress = "localhost"; String strDatabaseName = "AdventureWorks"; String url = "jdbc: sqlserver: // "+ strServerIPAddress +": 1433 "+"; DatabaseName = "+ strDatabaseName; String strUserName =" sa "; String strPassword =" 123456 "; // Connection conn = null; try {// Register the driver Class. forName ("com. microsoft. sqlserver. jdbc. SQLServerDriver "). newInstance (); try {/* Get a connection to the database */conn = DriverManager. getConnection (url, strUserName, strPassword);} catch (SQLException ex) {System. out. println ("Exception One:"); ex. printStackTrace () ;}} catch (Exception ex) {System. out. println ("Exception Two:"); ex. printStackTrace ();} System. out. println ("Connected... "); return conn;} public static void SQLServer_select () {// this code just for SQL Server try {String strCmd =" SELECT * FROM Production. location "; rs = stmt.exe cuteQuery (strCmd); while (rs. next () {System. out. println ("Column 1 has value:" + rs. getString (1); System. out. println ("Column 2 has value:" + rs. getString (2); System. out. println ("Column 3 has value:" + rs. getString (3) ;}} catch (SQLException ex) {System. out. println ("SQLException:" + ex. getMessage (); System. out. println ("SQLState:" + ex. getSQLState (); System. out. println ("VendorError:" + ex. getErrorCode ());}}