急问:连接MSSQL出问题了,谢谢
在连接MSSQL时出问题了以下是代码
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import
java.sql.SQLException;
public class check_login extends db
{
public String check(String username)
{
String driver= "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=newweb ";
String user= "sa ";
String dbpassword= "111111 ";
String pwd=null;
try
{
Class.forName(driver);
Connection con=DriverManager.getConnection(url,user,dbpassword);
String query= "select * from user ";
PreparedStatement prestatement=con.prepareStatement(query);
ResultSet result=prestatement.executeQuery(query);
while(result.next())
{
System.out.println(pwd);
}
}
catch(
SQLException e)
{
e.printStackTrace();
}
catch(
ClassNotFoundException e)
{
e.printStackTrace();
}
return pwd;
}
}
可是错误很奇怪
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at &n