try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection
(
"jdbc://mysql://3306/localhost/labour",
"root",
"pb"
);
Statement st=con.createStatement();
String query="select userid,password from userregiter";
ResultSet rs= st.executeQuery(query);
while(rs.next())
{
String userid=rs.getString("USERID");
String password=rs.getString("PASSWORD");
if ((a.equals(userid)) && (b.equals(password)))
{
JOptionPane.showMessageDialog(null, "Username and Password exist");
} else {
JOptionPane.showMessageDialog(null, "Please Check Username and Password ");
}
}
} catch(Exception e) {
System.out.println(e);
}错误:当我运行我的应用程序时,它显示了异常。
java.sql.SQLException: No suitable driver found for jdbc://mysql://3306/localhost/labour发布于 2015-06-08 08:59:28
您的db url必须看起来像:
DriverManager.getConnection("jdbc:mysql://localhost/labour);而且您的类路径中必须有mysql驱动程序。
有关更多细节,请参见正式文件。
https://stackoverflow.com/questions/30704859
复制相似问题