sqlserver java驱动_java加载sqlserver驱动失败

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:264)

at pDatabase.test1.main(test1.java:12)

package pDatabase;

import java.sql.*;

public class test1 {

public static void main(String[] args) {

Statement sm=null;

Connection ct=null;

try{

Class.forName

("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();

ct=DriverManager.getConnection("jdbc:odbc:sqldb","sa","130124");

sm=ct.createStatement();

int i=sm.executeUpdate("insert into dept values ('50','sec','newyork')");

if (i==1){

System.out.println("success");

}

}catch(Exception e){

e.printStackTrace();

}finally{

try {

if (sm!=null){

sm.close();

}

if(ct!=null){

ct.close();

}

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

这是什么原因?

你可能感兴趣的:(sqlserver,java驱动)