2 Replies Latest reply on Jun 17, 2006 5:12 AM by kurt_olsen

    How to set another HSQLDB datasource beside DefaultDS?

      I've been trying to set a second HSQLDB datasource besides DefaultDS? Could anyone help me to do this? Please

        • 1. Re: How to set another HSQLDB datasource beside DefaultDS?
          kurt_olsen

          For 4.0.4.GA you can try this:

          I installed jboss using the installer.jar, and selected the ejb3-clustered profile which I subsequently renamed as 'all'

          Delete jboss/server/all/deploy/hsqldb-ds.xml

          Create a new datasource by copying the template for your specific database from jboss/docs/examples/jca to jboss/server/all/deploy

          ie. COPY jboss/docs/examples/jca/mysql-ds.xml TO jboss/server/all/deploy/default-ds.xml

          Edit default-ds.xml

          Change the jndi-name to DefaultDS
          Provide your connection parameters, username password etc
          I used the same database name hsqldb-ds.xml used - 'localDB'
          here is what I used for mysql


          <datasources>
           <local-tx-datasource>
           <jndi-name>DefaultDS</jndi-name>
           <connection-url>jdbc:mysql://localhost:3306/localDB?createDatabaseIfNotExist=true</connection-url>
           <driver-class>com.mysql.jdbc.Driver</driver-class>
           <user-name>root</user-name>
           <password></password>
           <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
           <!-- sql to call when connection is created
           <new-connection-sql>some arbitrary sql</new-connection-sql>
           -->
           <!-- sql to call on an existing pooled connection when it is obtained from pool
           <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
           -->
          
           <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
           <metadata>
           <type-mapping>mySQL</type-mapping>
           </metadata>
           </local-tx-datasource>
          </datasources>
          


          Edit jboss/server/all/conf/standardjaws.xml

          Change the type-mapping, in my case to 'mySQL'

          Now we have to make jms happy by copying a specific template for your database from jboss/docs/examples/jms to jboss/server/all/deploy/jms

          ie. COPY joss/docs/examples/jms/mysql-jdbc2-service.xml TO jboss/server/all/deploy/jms/mysql-jdbc2-service.xml

          Edit the file file and change the datasource name it uses.
          I had to change mine from MySqlDS to DefaultDS

          Delete jboss/server/all/deploy/jms/hsqldb-jdbc2-service.xml

          DO NOT delete hsqldb-jdbc-state-service.xml (I suspect this should be replaced also, but I couldn't figure out what to replace it with).

          I suspect that other changes might have to be made. The JBoss documentation didn't discuss this. After changing the default ds I was able to sucessfully deploy one ejb3 entity and exercise it thru a stateless session bean -the server boots without exceptions, the ejb3 deploys and works, and it used my database...

          I'll post again if I learn more.






          • 2. Re: How to set another HSQLDB datasource beside DefaultDS?
            kurt_olsen

            It looks like I misunderstood your initial posting.

            The procedure I specified is how to change the default datasource.
            Not how to use a second hypersonic db.

            The mysql connector/mxj can embed, and start a mysql database when
            jboss boots. Then, if you need another datasource, just add another *-ds.xml
            file to the deploy dir and tell it to use another database name.

            I suspect this is easier than teaching a second instance of hypersonic where
            to put it's data. On the other hand, I looked for and found good hypersonic
            docs on the web once and found it to be quite powerful and the docs were
            very clear. Have fun, good luck!