java程序谁给运行一 并告诉我怎样才能成功
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:PIMS", "Test", "000123");stmt=con.createStatement();if(choice.getSelectedItem().equals("学生")) { boolean tag=false; rs=stmt.executeQuery("select * From 学生基本信息"); while(rs.next()) { if(rs.getInt("密码")==Int1 && rs.getString("学号").equals(ID)) { getJFrame2().setVisible(true); setVisible(false); tag=true; break; } if(jTextField.getText().equals("")) { JOptionPane.showMessageDialog(null, "用户名不能为空"); jPasswordField.setText(null); tag=true; break; } }if(tag==false){ JOptionPane.showMessageDialog(null, "用户名或密码错误"); jPasswordField.setText(null); }}else if(choice.getSelectedItem().equals("教师")){ boolean tag=false; rs=stmt.executeQuery("select * From 教师基本信息"); while(rs.next()) { if(rs.getInt("密码")==Int1 && rs.getString("教工号").equals(ID)) { getJFrame3().setVisible(true); jPanel1.setVisible(false); setVisible(false); tag=true; break; } if(jTextField.getText().equals("")) { JOptionPane.showMessageDialog(null, "用户名不能为空"); jPasswordField.setText(null); tag=true; break; } } if(tag==false) { JOptionPane.showMessageDialog(null, "用户名或密码错误"); jPasswordField.setText(null); } } stmt.close(); con.close(); } catch(Exception ex){ JOptionPane.showMessageDialog(null, "请注册用户"); }
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:PIMS", "Test", "000123");stmt=con.createStatement();if(choice.getSelectedItem().equals("学生")) { boolean tag=false; rs=stmt.executeQuery("select * From 学生基本信息"); while(rs.next()) { if(rs.getInt("密码")==Int1 && rs.getString("学号").equals(ID)) { getJFrame2().setVisible(true); setVisible(false); tag=true; break; } if(jTextField.getText().equals("")) { JOptionPane.showMessageDialog(null, "用户名不能为空"); jPasswordField.setText(null); tag=true; break; } }if(tag==false){ JOptionPane.showMessageDialog(null, "用户名或密码错误"); jPasswordField.setText(null); }}else if(choice.getSelectedItem().equals("教师")){ boolean tag=false; rs=stmt.executeQuery("select * From 教师基本信息"); while(rs.next()) { if(rs.getInt("密码")==Int1 && rs.getString("教工号").equals(ID)) { getJFrame3().setVisible(true); jPanel1.setVisible(false); setVisible(false); tag=true; break; } if(jTextField.getText().equals("")) { JOptionPane.showMessageDialog(null, "用户名不能为空"); jPasswordField.setText(null); tag=true; break; } } if(tag==false) { JOptionPane.showMessageDialog(null, "用户名或密码错误"); jPasswordField.setText(null); } } stmt.close(); con.close(); } catch(Exception ex){ JOptionPane.showMessageDialog(null, "请注册用户"); }
解决方案 »
- spring placeholderConfig的问题
- 急 ajax 返回值js不执行
- 页面内嵌Frame的问题
- 一个人做出和当当网一样功能的网站需要多长时间
- 快来看看吧
- 软件包 javax.servlet 不存在???
- 各位兄弟,请帮我看看这段代码的问题在哪儿?在线等,解决立马给分!
- page="../foo/bar.jsp"表示什么?
- PrintWriter out = new PrintWriter(new GZIPOutputStream(out1),false);不理解是什么意思。
- 程序更新的时候总是更新漏了,谁有好的解决办法哦
- 为什么用request.setAttribute传值取出来的是null
- 谁有Javascript css Compress使用说明?
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:PIMS", "Test", "000123");
stmt=con.createStatement();
if(choice.getSelectedItem().equals("学生")){
boolean tag=false;
rs=stmt.executeQuery("select * From 学生基本信息");
while(rs.next()){
if(rs.getInt("密码")==Int1 && rs.getString("学号").equals(ID)){
getJFrame2().setVisible(true);
setVisible(false);
tag=true;
break;
}
if(jTextField.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "用户名不能为空");
jPasswordField.setText(null);
tag=true;
break;
}
}
if(tag==false){
JOptionPane.showMessageDialog(null, "用户名或密码错误");
jPasswordField.setText(null);
}
}else if(choice.getSelectedItem().equals("教师")){
boolean tag=false;
rs=stmt.executeQuery("select * From 教师基本信息");
while(rs.next()){
if(rs.getInt("密码")==Int1 && rs.getString("教工号").equals(ID)){
getJFrame3().setVisible(true);
jPanel1.setVisible(false);
setVisible(false);
tag=true;
break;
}
if(jTextField.getText().equals("")){
JOptionPane.showMessageDialog(null, "用户名不能为空");
jPasswordField.setText(null);
tag=true;
break;
}
}
if(tag==false){
JOptionPane.showMessageDialog(null, "用户名或密码错误");
jPasswordField.setText(null);
}
}
stmt.close();
con.close();
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, "请注册用户");
}
choice.getSelectedItem()是什么?这个可以获取到值吗?
Int1,ID都是什么?jTextField.getText().equals("")这句最好改成 "".equals(jTextField.getText());
Int1,ID从哪里来的?jTextField.getText().equals("")如果这里是获取用户名,那么是否在sql检索里加上条件比较好,不用全检索再比较吧String username = jTextField.getText();
if (username == null || "".equals(username.trim())) {
JOptionPane.showMessageDialog(null, "用户名不能为空");
jPasswordField.setText(null);
return;
}
boolean tag=false;
if(choice.getSelectedItem().equals("学生")){
rs=stmt.executeQuery("select * From 学生基本信息 where username = '"
+ username + "'");
while(rs.next()){
if(rs.getInt("密码")==Int1 && rs.getString("学号").equals(ID)){
getJFrame2().setVisible(true);
setVisible(false);
tag=true;
break;
}
}} else if (choice.getSelectedItem().equals("教师")) {
rs=stmt.executeQuery("select * From 教师基本信息 where username = '"
+ username + "'");
while(rs.next()){
if(rs.getInt("密码")==Int1 && rs.getString("教工号").equals(ID)){
getJFrame3().setVisible(true);
jPanel1.setVisible(false);
setVisible(false);
tag=true;
break;
}
}
}
if(tag==false){
JOptionPane.showMessageDialog(null, "用户名或密码错误");
jPasswordField.setText(null);
}
qybao的指明,
部分参数的确来源不明,类型不清楚