2 Replies Latest reply on Mar 20, 2012 4:03 PM by Dale Booth

    JDBC Data Source connection creation - help

    Dale Booth Newbie

      I have successfully got a JNDI data source working in JBoss 7.1.x.  However, when I attempt to set up a JDBC data source connection I run into issues.  I've read through many of the JBoss 7 documentation sites / JBoss dicussions / search sites, but have not found the correct solution. 


      I've started with a standalone installation. The datasource section in my standalone.xml file contains the following:


      <datasource jta="true" jndi-name="java:jboss/datasources/testDS" pool-name="testDS" enabled="true" use-java-context="true" use-ccm="true">















              <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>









          <driver name="h2" module="com.h2database.h2">



          <driver name="postgresql-9.1-901.jdbc4.jar" module="org.postgresql"/>



      NOTE: I found one site that stated that the use-java-context="false" would work, but didn't for me


      I have tried using both methods of pushing out the database driver: module AND deployment.  I have gone with the module method.

      I created the appropriate modules directory structure and files.  My module.xml file contains:


      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.0" name="org.postgresql">


              <resource-root path="postgresql-9.1-901.jdbc4.jar"/>



              <module name="javax.api"/>

      <!--        <module name="javax.transaction.api"/>  --> <!-- Only necessary on Linux and Mac -->




      In my application I have a jboss-web.xml file which contains:


      <?xml version="1.0" encoding="UTF-8" ?>











      When I attempt to change the jndi-name to include jdbc I get a message stating that the jndi-name must start with "java:" OR "java:jboss..."


      I have seen references to persistence.xml, but this file doesn't exist in a default JBoss 7.x installation.  I have also seen a could of references to jndi-name="java:jboss/jdbc/yourDS", but JBoss 7 appears to want jndi-name="java:jboss/datasource/yourDS".


      What am I missing?  Any help would be appreciated


      Thank you


        • 1. Re: JDBC Data Source connection creation - help
          jaikiran pai Master

          Dale, welcome to the forums!


          It isn't clear what error you are running into and with what configuration. Can you please post the exact configuration(s) and exception stacktrace that you see?

          • 2. Re: JDBC Data Source connection creation - help
            Dale Booth Newbie

            Thank you for your reply.


            Regarding your questions:



            The only change I made to the standalone.xml file was with the DS name info "testDS".  The rest of the file was the same.  The other two files were the same as well.


            Exception / Stack trace:

            At the time of the post no errors were getting outputted.  I talked with a colleague and we were able to get an error.  ClassNotFoundException for the org.postgresql.Driver.  


            Resolved Issue:

            I was able to resolve the JDBC Connection issue by copying the PostgreSQL Driver jar into the ..\WEB-INF\lib directory of the application.



            FYI...Thanks again,