Основна функция:
String g_sid = "";
Нишка 1:
String sql = ...;
Connection conn = ...your connection func...;
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery( "SELECT sid from v$mystat");
if (rset.next()) g_sid = rset.getString("sid");
rset.close();
// now to the actual long-running SQL
ResultSet rset = stmt.executeQuery( sql );
//
stmt.close();
Нишка 2:
String serialN = "";
Connection conn = ...your admin connection func...
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery( "SELECT serial# serialN from v$session where sid=" + g_sid );
if (rset.next()) {
serialN = rset.getString("serialN");
stmt.execute("alter system kill session '" + g_sid + "," + serialN + "'");
}
stmt.close();
// probably keep the admin connection open for further maintenance
//