Netbeans swing 编程,
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement; public void run() {
new Login().setVisible(true);
} 的run都显示未使用导入 按钮代码: String password = new String(jPasswordField1.getPassword());
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Database", "sa", "");
Statement stmt = con.createStatement();
String sql = "select password from password where password='" + password + "'";
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
password = rs.getString("password");
jPasswordField1.setText(password);
new Main().setVisible(true);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException e) {
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement; public void run() {
new Login().setVisible(true);
} 的run都显示未使用导入 按钮代码: String password = new String(jPasswordField1.getPassword());
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Database", "sa", "");
Statement stmt = con.createStatement();
String sql = "select password from password where password='" + password + "'";
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
password = rs.getString("password");
jPasswordField1.setText(password);
new Main().setVisible(true);
}
} catch (ClassNotFoundException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException e) {
}
ResultSet rs = stmt.executeQuery(sql);
是不是表名错了 你确实是password?
Swing,自动生成代码监听