错误的多次获取oracle.jdbc.driver.T4CConnection连接,导致tomcat突然停止
来源:互联网 发布:淘宝卖家如何参加鹊桥 编辑:程序博客网 时间:2024/06/05 05:13
/** * 功能描述:获取oracle连接 * @param con * @return * @throws SQLException */public static Connection getOracleConnection() throws SQLException {Connection conn = getConnection();// 获取connectionif (conn instanceof DelegatingConnection) {Connection nativeCon = ((DelegatingConnection) conn).getInnermostDelegate();/* For some reason, the innermost delegate can be null: not for a* Statement's Connection but for the Connection handle returned by the pool.* We'll fall back to the MetaData's Connection in this case, which is* a native unwrapped Connection with Commons DBCP 1.1.*/return (nativeCon != null ? nativeCon : conn.getMetaData().getConnection());}return conn;}
获取完这个连接后,又有了一下的代码
try {conn = DataAccess.getOracleConnection(); String sql = "{call updateStorageFlag(?,?,?,?)}"; proc = conn.prepareCall(sql); ArrayDescriptor desc = ArrayDescriptor.createDescriptor("ARRAY_BARCODEID", conn);// 大写,不然会报“无效的名称模式” ARRAY arr1 = new ARRAY(desc, conn, barcodeArray); desc = ArrayDescriptor.createDescriptor("ARRAY_BOXID", conn);// 大写,不然会报“无效的名称模式” ARRAY arr2 = new ARRAY(desc, conn, boxArray); proc.setString(1, allocationListNo);// 订单号 proc.setObject(2, arr1, Types.ARRAY);// 条形码数组 proc.setObject(3, arr2, Types.ARRAY);// 箱号数组 proc.setString(4, flag);proc.execute();//System.out.println("成功的记录数="+resultList.get(0));//System.out.println("未成功插入的条形码="+resultList.get(1));} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();sign = false;}finally{DataAccess.Close(conn, proc);}System.out.println("是否关闭-"+conn.isClose()+" conn="+conn);<span style="color:#FF0000;">// 虽然结果是true,但是conn还是有值的(我的连接池用的是dbcp)</span>当我把DBCP的最大活动连接设为10时,当点击第11次时,tomcat就直接down掉了,百思不得其解啊,最后仔细琢磨琢磨原来是连接池中的连接根本就没关掉,连接池已经耗尽了,将上面的方式改改,最终的代码如下:
/** * 功能描述:获取oracle连接 * @param con * @return * @throws SQLException */public static Connection getOracleConnection(<span style="color:#FF0000;">Connection conn</span>) throws SQLException {if (conn instanceof DelegatingConnection) {Connection nativeCon = ((DelegatingConnection) conn).getInnermostDelegate();/* For some reason, the innermost delegate can be null: not for a* Statement's Connection but for the Connection handle returned by the pool.* We'll fall back to the MetaData's Connection in this case, which is* a native unwrapped Connection with Commons DBCP 1.1.*/System.out.println("getOracleConnection="+(nativeCon != null ? nativeCon : conn.getMetaData().getConnection()));return (nativeCon != null ? nativeCon : conn.getMetaData().getConnection());}return conn;}
try {conn = DataAccess.getConnection(); String sql = "{call updateStorageFlag(?,?,?,?)}"; proc = conn.prepareCall(sql); ArrayDescriptor desc = ArrayDescriptor.createDescriptor("ARRAY_BARCODEID", DataAccess.getOracleConnection(conn));// 大写,不然会报“无效的名称模式” ARRAY arr1 = new ARRAY(desc, DataAccess.getOracleConnection(conn), barcodeArray); desc = ArrayDescriptor.createDescriptor("ARRAY_BOXID", DataAccess.getOracleConnection(conn));// 大写,不然会报“无效的名称模式” ARRAY arr2 = new ARRAY(desc, DataAccess.getOracleConnection(conn), boxArray); proc.setString(1, allocationListNo);// 订单号 proc.setObject(2, arr1, Types.ARRAY);// 条形码数组 proc.setObject(3, arr2, Types.ARRAY);// 箱号数组 proc.setString(4, flag);proc.execute();//System.out.println("成功的记录数="+resultList.get(0));//System.out.println("未成功插入的条形码="+resultList.get(1));} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();sign = false;}finally{DataAccess.Close(conn, proc);}
所以啊,写代码一定要仔细啊
0 0
- 错误的多次获取oracle.jdbc.driver.T4CConnection连接,导致tomcat突然停止
- locked <0xd01eb358> (a oracle.jdbc.driver.T4CConnection
- JSP Tomcat8.0运行连接池时发生异常【AbstractMethodError oracle.jdbc.driver.T4CConnection.isValid(I)Z】
- 解决oracle 10g 异常:AbstractMethodError:oracle.jdbc.driver.T4CConnection.isValid(I)Z
- Exception in thread "main" java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection cannot be
- The Network Adapter could not establish the connection at oracle.jdbc.driver.T4CConnection.logon
- oracle.jdbc.driver.T4CConnection.unwrap(Ljava/lang/Class;)启动项目监听数据库表
- Java连接oracle的关于oracle.jdbc.driver.OracleDriver的错误的解决
- Java连接oracle的关于oracle.jdbc.driver.OracleDriver的错误的解决
- oracle.jdbc.driver连接数据库
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 错误的解决办法
- OCI方式连接Oracle数据库抛出错误 java.lang.UnsatisfiedLinkError: oracle.jdbc.driver.T2CConnection.getLibraryVer
- tomcat 启动到Loaded JDBC driver:com.mysql.jdbc.Driver停止
- 采用oracle.jdbc.driver.OracleDriver连接数据库
- java.lang.AbstractMethodError:oracle.jdbc.T4CConnection.createClob()Ljava
- Tomcat 运行 CAS + Oracle 应用的时候 报错 Could not load oracle.jdbc.driver.Accessor.
- 错误处理Cannot load JDBC driver class 'oracle.jdbc.drive
- oracle jdbc连接数据库的源代码分析之获取连接
- SQL知识总结
- pku1734 Musical Theme
- [ACM] HDU 5131 Song Jiang's rank list (模拟)
- 菜鸟授徒系列之母函数
- 如何将你的Sprite Kit游戏从ios移植到Mac OS X平台
- 错误的多次获取oracle.jdbc.driver.T4CConnection连接,导致tomcat突然停止
- S2SH框架配置步骤
- oVirt 3.3 gluster volume active but unable to activate domain
- poj1745 dp
- The Reconstruction Toolkit (RTK) 编译
- 获取磁盘相关信息以及网卡相关信息
- C++中堆和栈内存分配
- android编译时报错:Error parsing XML: unbound prefix 的错误原因及解决方案
- 跪求解脱,MVC中的M让人吐血...