public ResultSet executeQuery(String strSQL)
{
rs = null;
try
{
jdbc_sql();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(strSQL);
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null,"データベースは誤りにつながる" + ex.getMessage());
System.out.println(ex.getMessage());
bln = false;
}
return rs;
}public void executeUpdate(String strSQL)
{
try
{
jdbc_sql();
stmt = conn.createStatement();
stmt.executeQuery(strSQL);
}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null,"データベースは誤りにつながる" + ex.getMessage());
System.err.println(ex.getMessage());
bln = false;
}
}这样写的话,我每调一次executeUpdate,都会开一次数据库(关数据库在其他地方执行),有没有什么好解决方案能在程序刚运行时就开一次数据库,程序关闭的时候再关掉连接