数据插入问题
有如下代码:
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:tax");
Statement stmt1=conn.createStatement();
for(i=0;i<3;i++)
{
ResultSet rss=stmt1.executeQuery("insert into 1 values('1','2','3','3','3','3')");
JOptionPane.showMessageDialog(null, "数据库连接失败,请重新连接!", "警告", JOptionPane.ERROR_MESSAGE);
}
}
catch(java.lang.ClassNotFoundException e1)
{
JOptionPane.showMessageDialog(null, " 数据库连接失败,请重新连接!", "警告", JOptionPane.ERROR_MESSAGE);
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null, " 数据库连接失败,请重新连接!", "警告", JOptionPane.ERROR_MESSAGE);
}
按道理来说,应该执行3次insert语句,即插入3条记录,但为什么只插入一条记录,而且JOptionPane.showMessageDialog(null, "数据库连接失败,请重新连接!", "警告", JOptionPane.ERROR_MESSAGE);这句代码并未执行