日期:2014-05-20 浏览次数:20745 次
try
{
con=DriverManager.getConnection(connectionUrl); //创建数据库连接
Statement stat=con.createStatement();
//定义变量保存用户输入的数据
String name=txtName.getText().trim();
int icode=Integer.parseInt(txtCode.getText().trim());
float java=Float.parseFloat(txtJava.getText().trim());
float web=Float.parseFloat(txtWeb.getText().trim());
float english=Float.parseFloat(txtEnglish.getText().trim());
float vb=Float.parseFloat(txtVB.getText().trim());
float oracle=Float.parseFloat(txtOracle.getText().trim());
String updateStr="insert into info(Name,Code,scoreJava,scoreWeb,scoreVB,scoreEnglish,scoreOracle) values('"+name+"',icode,java,web,vb,english,oracle)";
//String updateStr="insert into info(Name,Code,scoreJava,scoreWeb,scoreVB,scoreEnglish,scoreOracle)values('test',10,10,10,10,10,10)";
stat.executeUpdate(updateStr);
}
catch(SQLException ex)
{
System.out.println("发生异常了:"+ex.getMessage());
}
String updateStr="insert into info(Name,Code,scoreJava,scoreWeb,scoreVB,scoreEnglish,scoreOracle) values('"+name+"',icode,java,web,vb,english,oracle)";
String updateStr="insert into info(Name,Code,scoreJava,scoreWeb,scoreVB,scoreEnglish,scoreOracle) values('"+name+"','"+icode+"','"+java+"','"+web+"','"+vb+"','"+english+"','"+oracle+"')";
String updateStr="insert into info(Name,Code,scoreJava,scoreWeb,scoreVB,scoreEnglish,scoreOracle) values('"+name+"',icode,java,web,vb,english,oracle)";