[求助]数据库连接问题(版主帮帮忙!)
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{
System.out.print("开始");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.print("success!");
}catch(Exception e)
{System.out.print("false");}
try{ Connection con=DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=D:\\Program Files\\javaworkspace\\JavaApplication5\\教务.mdb");
Statement usest=con.createStatement();
String sql="select psw from student where number="+jTextField1.getText();
ResultSet r=usest.executeQuery(sql);
if(r.getString(1).equals(jTextField2.getText()))
{ JOptionPane.showMessageDialog(null, "提示", "登陆成功!", JOptionPane.OK_OPTION);
new xue().setVisible(true);
this.setVisible(false);
con.close();
usest.close();
r.close();
}
else
{JOptionPane.showMessageDialog(null, "提示222", "登陆成功!", JOptionPane.OK_OPTION);
new xue().setVisible(true);}
}
catch(Exception e)
{Object[] options = { "OK" };
JOptionPane.showOptionDialog(this, "用户名或密码错误","提示!",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
e.printStackTrace();}
}
这是一段处理BUTTON事件代码
出现以下异常: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
请教各位!谢谢
[此贴子已经被作者于2007-7-15 10:28:39编辑过]