SQL连接数据库
这是我照书打的程序,编译没问题,运行时出现这样的错误:未找到要加载的驱动类请问一下高手,我这个程序应该怎样修改呢?
import java.sql.*;
public class SQL_JDBC{
public static void main(String[]args){
Connection conn;
String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=MIS";
String user="sa";
String pwd="";
try{
Class.forName(driver);
conn=DriverManager.getConnection(url,user,pwd);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql="select * from users";
ResultSet rs=stmt.executeQuery(sql);
System.out.println("......................................");
while(rs.next()){
System.out.print(" "+rs.getString(1));
System.out.println("\t"+rs.getString(2));
/* System.out.print("Birthday:"+rs.getDate(3)+"\t");
System.out.print("Sex:"+rs.getInt(4)+"\t");
System.out.println();*/
}
stmt.close();
conn.close();
System.out.print("\n"+"TestOK!");
}catch(ClassNotFoundException e){System.out.println("未找到要加载的驱动类");
}catch(SQLException e){
System.out.println("SQL错误提示:"+e);
}
}
}