我有这部分代码
try
{
Connection conn=new DBconnect().con();
Statement stmt=new DBconnect().stm(conn);
//Statement stmt2=new DBconnect().stm(conn);
ResultSet rs = stmt.executeQuery( "UPDATE bill SET REMAIND_FREE_TIME="+FreeTimeN+"WHERE telephone="+tel);
// ResultSet rs2 = stmt2.executeQuery(" UPDATE bill SET REMAIND_FREE_TIME="+FreeTimeN2+"WHERE telephone="+tel2);
问题是,每当我使用一个更新运行它时,一切都很好,但是当我同时运行它们时会出错。这是数据库类:
package database_console;
import frames.login;
import java.sql.*;
public class DBconnect {
Statement stmt;
ResultSet rs;
Connection conn;
public Connection con() throws ClassNotFoundException, SQLException{
Class.forName( "oracle.jdbc.OracleDriver" ) ;
// Get a connection to the database
conn = DriverManager.getConnection( "jdbc:oracle:thin:@83.212.240.15:1521:orcl","it21119", "a37161637" ) ;
return conn;
}
public Statement stm(Connection conn) throws SQLException {
// Get a statement from the connection
stmt = conn.createStatement() ;
return stmt;
}
public void stop(Connection conn,Statement stmt, ResultSet rs) throws SQLException{
rs.close() ;
stmt.close() ;
conn.close() ;
}
}
有什么建议吗?提前谢谢。(顺便说一句,我正在使用带有 ojdbc6.jar 的 sqldeveloper)