该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
public void actionPerformed(ActionEvent ae)
{
String recode,insert1,编号,姓名;
int 电话;
if(ae.getSource()==btnCancel)
{
this.dispose();
}
else if(ae.getSource()==btnAdd)
{
try
{//Class.forName("com.mysql.jdbc.Driver");}
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e){
System.out.println("异常");}
//Class.forName("com.mysql.jdbc.Driver");
//conn2=DriverManager.getConnection("jdbc:mysql://localhost:3307/haier","root", "123")
try{con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
// con=DriverManager.getConnection("jdbc:mysql://localhost:3307/haier","root", "123");
sql=con.createStatement();
姓名=txtName.getText();
编号=txtDate.getText();
电话=Integer.parseInt(txtScore.getText());
recode="("+"'"+姓名+"'"+","+"'"+编号+""+"',"+电话+")";
insert1="INSERT INTO 电话表 VALUES "+recode;
sql.executeUpdate(insert1);
System.out.println("记录添加完毕!");
btnAdd.setEnabled(false);
txtName.setText("");
txtScore.setText("");
txtDate.setText("");
con.close();
}
catch(SQLException e){System.out.println("异常");
}
}
}