我在Oracle里创建了一个会话级的临时表,用Java代码获得一个数据连接,代码如下: public Connection getConnection() throws Exception {
Connection conn = null;
Context ctx = new InitialContext();
try {
if (appKey != null) {
ds = (DataSource) ctx.lookup(ERPJNDI); // java:comp/env/jdbc/sce
}
if (ds == null) {
throw new Exception(
"SCEHelper can't find the datasource for SCE Database. " +
"Please check the System Property");
}
} catch (Exception ex) {
ex.printStackTrace();
} try {
if (ds != null) {
conn = ds.getConnection();
} else {
throw new Exception(
"SCEHelper can't find the datasource for SCE Database. " +
"Please check the System Property");
} } catch (Exception ex) {
System.out.println(
"/***********************************************");
System.out.println(
" + ");
System.out.println(
" Connection Error !! ");
System.out.println(ex.toString() +
" ");
System.out.println(
"************************************************/");
throw ex;
}
return conn;
}
然后在其他代码中调用调用了那个临时表,取出运算后的数据,并且关闭连接,怎么我下次再运行程序的时候,原来临时表中的数据怎么还在啊。怎么会话级临时表的数据在连接断开后不会自动清除啊!
Connection conn = null;
Context ctx = new InitialContext();
try {
if (appKey != null) {
ds = (DataSource) ctx.lookup(ERPJNDI); // java:comp/env/jdbc/sce
}
if (ds == null) {
throw new Exception(
"SCEHelper can't find the datasource for SCE Database. " +
"Please check the System Property");
}
} catch (Exception ex) {
ex.printStackTrace();
} try {
if (ds != null) {
conn = ds.getConnection();
} else {
throw new Exception(
"SCEHelper can't find the datasource for SCE Database. " +
"Please check the System Property");
} } catch (Exception ex) {
System.out.println(
"/***********************************************");
System.out.println(
" + ");
System.out.println(
" Connection Error !! ");
System.out.println(ex.toString() +
" ");
System.out.println(
"************************************************/");
throw ex;
}
return conn;
}
然后在其他代码中调用调用了那个临时表,取出运算后的数据,并且关闭连接,怎么我下次再运行程序的时候,原来临时表中的数据怎么还在啊。怎么会话级临时表的数据在连接断开后不会自动清除啊!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货