错误:
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==enter)
{
String str="select id,pw from user";
mydbcon my;
Connection conn = null;
my = new mydbcon(); //有红线错误,光标放在上面提示我Surround with try/catch
conn = my.getconnection();
Statement stm=conn.createStatement();//同上错误
ResultSet rs=stm.executeQuery(str);//同上错误
..........
正确
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==enter)
{
String str="select id,pw from user";
mydbcon my;
Connection conn = null;
try {
my = new mydbcon();
conn = my.getconnection();
Statement stm=conn.createStatement();
ResultSet rs=stm.executeQuery(str);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
?
是王小二呀
qq_蓝色心魂_0
Its_forever
相关分类