2 Replies Latest reply on Sep 19, 2006 9:24 AM by Rajesh Chande

    java.sql.SQLException: Already closed

    Peter Pei Guo Newbie

      In my web service, I need to access Oracle database, so I created the oracle-ds.xml file in my deploy directory like this:
      <?xml version="1.0" encoding="UTF-8"?>


      <local-tx-datasource>
      <jndi-name>hhsDB</jndi-name>
      <connection-url>jdbc:oracle:thin:@aadv1db.abcd.com:1521:aadv1</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>sim</user-name>
      sim
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>

      <type-mapping>Oracle10g</type-mapping>

      </local-tx-datasource>


      And in my code I have this function to get connection for me:
      private Connection getConnection() throws Exception {

      InitialContext initialContext = new InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource) initialContext.lookup("java:hhsDB");
      java.sql.Connection conn = ds.getConnection();
      return conn;
      }

      But it keeps giving me "java.sql.SQLException: Already closed", even after I removed those .close() calls from my code... What should I do?