3 Replies Latest reply on Jun 23, 2006 9:55 AM by Martin Thorpe

    Datasource error

    Martin Thorpe Newbie


      I have this datasource set up in my struts config, running JBoss 4.0.4, and on starting the server I am getting the below error.

      From what I can see from the error I might have the details of the datasource incorrect, so can someone tell me what is supposed to go where? I am on Oracle 9i.

      This property should it be host:port:database?

       <set-property property="url" value="jdbc:oracle:thin:@localhost:1521:PROD2" />
      

      This property would be my service name in Oracle
      <set-property property="username" value="BIZZ_COOP" />

       <data-source key="bizzCoop" type="org.apache.commons.dbcp.BasicDataSource">
       <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
       <set-property property="url" value="jdbc:oracle:thin:@localhost:1521:PROD2" />
       <set-property property="username" value="BIZZ_COOP" />
       <set-property property="password" value="coop" />
       <set-property property="maxActive" value="10" />
       <set-property property="maxWait" value="5000" />
       <set-property property="defaultAutoCommit" value="false" />
       <set-property property="defaultReadOnly" value="false" />
       <set-property property="validationQuery" value="SELECT SYSDATE FROM DUAL" />
       </data-source>
      


      ----start of error
      Caused by: java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(
      TMP=)(VSNNUM=150999297)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
       at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
       at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:361)
      
       at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
      va:442)
       at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
       at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(Driv
      erConnectionFactory.java:37)
       at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(Poolable
      ConnectionFactory.java:290)
       at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(Bas
      icDataSource.java:877)
       at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
      rce.java:851)
       ... 141 more
      ----
      


      Thanks for reading

      cheers
      Martin

        • 2. Re: Datasource error
          Martin Thorpe Newbie

          Hello.

          Thanks for the links. I did have a look at these but I did not want to make it JBoss specific in case I need to move to another server such as weblogic which is highly likely in my situation.

          Hence putting the datasource in Struts.

          Thanks for your reply.

          cheers
          Martin

          • 3. Re: Datasource error
            Martin Thorpe Newbie

            Ok well I got it sorted after a lot of googling and messing about. This is connecting to a remote Oracle database using a struts-config datasource:

            Now the main problem with me was connecting remotley and my Oracle TNS not configured correctly, it is corrupt locally so having real problems with that.

            The way it was sorted in the end was using a connection string to directly connect to Oracle.

            This is my struts-config datasource, the URL property is where all the action is:

            <data-sources>
             <data-source key="bizzCoop" type="org.apache.commons.dbcp.BasicDataSource">
             <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
             <set-property property="url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hereGoesTheHostNameOrIPAddressOfHost)(PORT=1521))(CONNECT_DATA=(SID=PROD2)))" />
             <set-property property="username" value="myUser" />
             <set-property property="password" value="myPass" />
             <set-property property="maxActive" value="10" />
             <set-property property="maxWait" value="5000" />
             <set-property property="defaultAutoCommit" value="false" />
             <set-property property="defaultReadOnly" value="false" />
             <set-property property="validationQuery" value="SELECT SYSDATE FROM DUAL" />
             </data-source>
            </data-sources>
            


            Also make sure to have these classes visible to the server; I have mine in the WEB-INF/lib directory:

            The last 2 are Oracle specific I think.

            commons-pool-1.3.jar
            commons-collections-3.2.jar
            jdbc2_0-stdext.jar
            classes12.jar