10 Replies Latest reply on Jul 21, 2005 6:00 PM by shonak valvekar

    Could not create connection !!

    shonak valvekar Newbie

      HI Everybody,

      I am new bie to JBoss and I am trying to connect Oracle and having some problems, would appreciate if somobody can respond urgently. I have ojdbc14.jar in WEB-INF/lib diretory
      Here are my app-ds.xml file

      code:
      --------------------------------------------------------------------------------

      <local-tx-datasource> <jndi-name>TEST_CONN</jndi-name> <use-java-context>false</use-java-context> <connection-url>jdbc racle:thin:@dev:1521:test_dev</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <connection-property name="autoCommit">false</connection-property> <user-name>sysadmin</user-name> sys_admin <blocking-timeout-millis>50000</blocking-timeout-millis> <!-- Checks the Oracle error codes and messages for fatal errors --> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> <new-connection-sql>select * from dual</new-connection-sql> </local-tx-datasource>

      --------------------------------------------------------------------------------



      web.xml --file

      code:
      --------------------------------------------------------------------------------

      <resource-ref> Test Database Connection Pool <res-ref-name>jdbc/TEST_CONN</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth></resource-ref>

      --------------------------------------------------------------------------------



      Here is the code by which I am trying to get the connection:

      code:
      --------------------------------------------------------------------------------

      private Context getInitialContext() throws NamingException { Context ctx = new InitialContext(); return ctx; }

      --------------------------------------------------------------------------------



      code:
      --------------------------------------------------------------------------------

      try { ds = (javax.sql.DataSource) getInitialContext().lookup( "TEST_CONN"); System.out.print("ds**********" + ds); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("cannot get database pool", e); } try{ Connection localConnection = ds.getConnection(); System.out.println("localConnection>>>>>>>>>>>>>" + localConnection); } catch(SQLException e){ e.printStackTrace(); } finally { try { if (localConnection != null) localConnection.close(); } catch (SQLException e) { log.error(e); }

      --------------------------------------------------------------------------------



      Here is the error:
      10:37:59,262 INFO [STDOUT] ds**********org.jboss.resource.adapter.jdbc.WrapperD
      ataSource@335053
      10:37:59,402 WARN [JBossManagedConnectionPool] Throwable while attempting to ge
      t a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested
      throwable: (org.jboss.resource.JBossResourceException: Apparently wrong driver
      class specified for URL: class: oracle.jdbc.driver.OracleDriver, url: jdbc racle:thin:@dev:1521:test_dev at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.c
      reateManagedConnection(LocalManagedConnectionFactory.java:161)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.cr
      eateConnectionEventListener(InternalManagedConnectionPool.java:508)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.ge
      tConnection(InternalManagedConnectionPool.java:207)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BaseP
      ool.getConnection(JBossManagedConnectionPool.java:534)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManage
      dConnection(BaseConnectionManager2.java:395)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedCo
      nnection(TxConnectionManager.java:297)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
      onnection(BaseConnectionManager2.java:447)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
      nManagerProxy.allocateConnection(BaseConnectionManager2.java:874)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp
      erDataSource.java:103)
      at com.exelixis.plateloader.ProcessBarcodeAction.execute(ProcessBarcodeA
      ction.java:78)
      at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
      tProcessor.java:421)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
      va:226)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
      4)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)

      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

        • 1. Re: Could not create connection !!
          jaikiran pai Master

          Your connection-url should be:

          <connection-url>jdbc:oracle:thin:@dev:1521:test_dev</connection-url>

          In your case, the jdbc:oracle is missing

          • 2. Re: Could not create connection !!
            shonak valvekar Newbie

            I am sorry I think there was some problem in pasting the error: I have the correct url:

            <connection-url>jdbc:oracle:thin:@dev:1521:test_dev</connection-url>

            I dont understand whats wrong with this url??

            • 3. Re: Could not create connection !!
              jaikiran pai Master

              Are you using the correct classes12.jar file

              • 4. Re: Could not create connection !!
                shonak valvekar Newbie

                I was using ojdbc14.jar file in the lib file...I deleted that jar file and copied the classes12.jar ..but now iam getting this new error..
                its unrelated error to my class....
                13:16:19,052 INFO [WebappClassLoader] Illegal access: this web application inst
                ance has been stopped already. Could not load org.hsqldb.jdbcDriver. The event
                ual following stack trace is caused by an error thrown for debugging purposes as
                well as to attempt to terminate the thread which caused the illegal access, and
                has no functional impact.
                13:16:19,052 WARN [JBossManagedConnectionPool] Throwable while attempting to ge
                t a new connection: null
                java.lang.ThreadDeath
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
                der.java:1221)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
                der.java:1181)
                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:217)
                at java.sql.DriverManager.getCallerClass(DriverManager.java:440)
                at java.sql.DriverManager.getDrivers(DriverManager.java:336)
                at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:294)
                at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.c
                reateManagedConnection(LocalManagedConnectionFactory.java:151)
                at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.cr
                eateConnectionEventListener(InternalManagedConnectionPool.java:508)
                at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.ge
                tConnection(InternalManagedConnectionPool.java:207)
                at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BaseP
                ool.getConnection(JBossManagedConnectionPool.java:534)
                at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManage
                dConnection(BaseConnectionManager2.java:395)
                at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedCo
                nnection(TxConnectionManager.java:297)
                at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
                onnection(BaseConnectionManager2.java:447)
                at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
                nManagerProxy.allocateConnection(BaseConnectionManager2.java:874)
                at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp
                erDataSource.java:103)
                at com.exelixis.plateloader.ProcessBarcodeAction.execute(ProcessBarcodeA

                • 6. Re: Could not create connection !!
                  Darran Lofthouse Master

                  Where is the *-ds.xml being deployed to?

                  • 7. Re: Could not create connection !!
                    shonak valvekar Newbie

                    Its been deployed to ..

                    C:\jboss-4.0.2\server\default\deploy


                    • 8. Re: Could not create connection !!
                      Darran Lofthouse Master

                      Try putting the JDBC jar in: -

                      C:\jboss-4.0.2\server\default\lib

                      • 9. Re: Could not create connection !!
                        shonak valvekar Newbie

                        I copied classes12.jar to C:\jboss-4.0.2\server\default\lib, now iam getting connection refused error ..i think i will go mad with this errors...

                        
                        14:45:11,484 INFO [STDOUT] DatasSource>>>>>>>>>org.jboss.resource.adapter.jdbc.
                        WrapperDataSource@18b4ccb
                        14:45:12,516 WARN [JBossManagedConnectionPool] Throwable while attempting to ge
                        t a new connection: null
                        org.jboss.resource.JBossResourceException: Could not create connection; - nested
                         throwable: (java.sql.SQLException: Io exception: Connection refused(DESCRIPTION
                        =(TMP=)(VSNNUM=153093120)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))))
                        
                         at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.c
                        reateManagedConnection(LocalManagedConnectionFactory.java:161)
                         at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.cr
                        eateConnectionEventListener(InternalManagedConnectionPool.java:508)
                         at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.ge
                        tConnection(InternalManagedConnectionPool.java:207)
                         at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BaseP
                        ool.getConnection(JBossManagedConnectionPool.java:534)
                         at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManage
                        dConnection(BaseConnectionManager2.java:395)
                         at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedCo
                        nnection(TxConnectionManager.java:297)
                         at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
                        onnection(BaseConnectionManager2.java:447)
                         at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio
                        nManagerProxy.allocateConnection(BaseConnectionManager2.java:874)
                         at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp
                        erDataSource.java:103)
                         at com.exelixis.plateloader.ProcessBarcodeAction.execute(ProcessBarcodeA
                        ction.java:78)
                        
                        


                        • 10. Re: Could not create connection !!
                          shonak valvekar Newbie

                          I solved the problem , connetion refused error is bcz ..my DBA changed the port number, thanks for ur help...