try{
String sql="insert into TBL_USER (uName) values ('yanshiwu')";
Connection conn=null;
Statement stmt=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(ClassNotFoundException e){
System.out.println("无法找到驱动类");
}
conn=DriverManager.getConnection ("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspbbs","sa","1");
stmt=conn.createStatement();
stmt.executeQuery(sql);
}catch(SQLException ee){
ee.getMessage();
}
给的错误是“无法找到驱动类”,是不是我没有把驱动包载入Java虚拟机?如何载入驱动呢?
String sql="insert into TBL_USER (uName) values ('yanshiwu')";
Connection conn=null;
Statement stmt=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(ClassNotFoundException e){
System.out.println("无法找到驱动类");
}
conn=DriverManager.getConnection ("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspbbs","sa","1");
stmt=conn.createStatement();
stmt.executeQuery(sql);
}catch(SQLException ee){
ee.getMessage();
}
给的错误是“无法找到驱动类”,是不是我没有把驱动包载入Java虚拟机?如何载入驱动呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货