0 Replies Latest reply on Jan 26, 2008 3:41 PM by KrazyK

    JNDI Prblem

      Hello, I have a JNDI datasource set up in the jrun-resources.xml file and I am using this simple class to access it and test a simple prepared statement. For some reason, this connection is not closing. I have made a coldfusion page and accessed this class and it keeps the connection open and shows up in Oracle as an inactive connection. Eventually we run out of connections and the database stops responding. We have a large java backend for our application and would like to use JNDI for the connection pooling. Can anyone tell my how to make the connections close??? A standard JDBC connection closes fine just not a JRUN JDNI managed connection.

      Here is the jrun resources entry.

      <!--<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class> -->

      Here is the class.

      public class TestJNDI {

      private String JNDIDatasourceName;

      public TestJNDI (String JNDIDatasource) {

      this.JNDIDatasourceName = JNDIDatasource;

      This is a test to see if a jrun managed connection is being closed


      public boolean Test() throws Exception {
      Connection connection = null;

      System.out.println("Looky here datasoure" + JNDIDatasourceName);
      jrun.sql.JRunConnectionHandle jCon = null;
      Context initialContext;
      javax.sql.DataSource ds = null;
      System.out.println("about to create initialContext");
      initialContext= new InitialContext();
      System.out.println("about to get datasource");
      ds = (javax.sql.DataSource) initialContext.lookup (JNDIDatasourceName);
      catch (NamingException e)
      System.out.println("Cannot create InitialContext" + e);

      //connection = jCon;
      System.out.println("about to get jcon");
      System.out.println("ds.getConnection() = " + ds.getConnection().getClass().getName());

      jCon = (jrun.sql.JRunConnectionHandle) ds.getConnection();

      // jCon = (jrun.sql.JRunConnectionHandle) ds.getConnection();
      // connection = ds.getConnection();
      // System.out.println("jCon = " + jCon.getClass().getName());
      connection = jCon.getPhysicalConnection();


      System.out.println("connection = " + connection.getClass().getName());

      PreparedStatement statement = connection.prepareCall("Select sysdate from dual");

      System.out.println("executing select from dual");

      System.out.print( statement.execute() );

      System.out.println("select from dual complete");





      catch ( ClassCastException e)
      System.out.println("a class cast has occured");
      catch ( Exception e)


      boolean booConn = connection.isClosed();

      System.out.println("connection " + booConn );

      return booConn;