为什么我的程序一开始是能通过的,但是我在前面加了句import java.sql.*;进去,别的什么都不改就出来5个错,都是关于Date()的 说找不到类了
[此贴子已经被作者于2007-1-24 17:45:46编辑过]
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if (source == b_sure) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("成功加载JDBC-ODBC驱动程序!");
}
catch (ClassNotFoundException ex) {
System.out.println("加载JDBC-ODBC驱动程序失败!");
System.out.println(ex.getMessage());
return;
}
try {
Connection connection = DriverManager.getConnection("jdbc:odbc:jxzlgl", "sa", "123456");
Statement st = connection.createStatement();
String query = "SELECT * FROM 用户表 WHERE 用户名='"+tf_id.getText()+"'";
ResultSet rs = st.executeQuery(query);
System.out.println(rs.getString("2"));
/*if (rs.next()) {
if (p_key.getText() != rs.getString(2)) {
JOptionPane.showMessageDialog(null, "密码错误!", "错误:", JOptionPane.ERROR_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null, "登陆成功", "!", JOptionPane.WARNING_MESSAGE);
}
}
else {
JOptionPane.showMessageDialog(null, "用户不存在!", "错误:", JOptionPane.ERROR_MESSAGE);
}*/
rs.close();
st.close();
connection.close();
}
catch(SQLException ec) {
System.out.println("查询数据库失败!");
System.out.println("SQLException:"+ec.getMessage());
}
}
}