7 Replies Latest reply on Jul 7, 2005 7:41 AM by Darran Lofthouse

    Multiple Datasources

    pablogra Newbie

      What do I do to have more than 1 datasource?
      I will de using the default hsql database for he JBoss services (for now),
      But my application uses SQL Server, so I creaed the following xml file and deplyed in the default server with the name myDB-ds.xml

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

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->

      <!-- $Id: mssql-ds.xml,v 1.3 2004/09/15 14:37:40 loubyansky Exp $ -->

      <!-- ======================================================================-->
      <!-- New ConnectionManager setup for Microsoft SQL Server 2000 driver -->
      <!-- You may download the latest Microsoft JDBC driver from *Microsoft* -->
      <!-- http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml&frame=true -->
      <!-- ===================================================================== -->


      <local-tx-datasource>
      <jndi-name>MyDatabase</jndi-name>
      <connection-url>jdbc:microsoft:sqlserver://myserver\\INST1:1433;DatabaseName=mydatabase</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>myuser</user-name>
      mypass
      <min-pool-size>5</min-pool-size>
      <max-pool-size>20</max-pool-size>
      <idle-timeout-minutes>0</idle-timeout-minutes>


      <!-- 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) -->

      <type-mapping>MS SQLSERVER2000</type-mapping>

      </local-tx-datasource>



      I connect to the datasource in a session bean and get alist of the database tables and get the hsql list of tables not the SQL erver list of tables.

      This is my lookup code:

      private javax.sql.DataSource getImpactDev() throws javax.naming.NamingException {
      javax.naming.Context c = new javax.naming.InitialContext();
      return (javax.sql.DataSource) c.lookup("java:comp/env/jdbc/MyDatabase");
      }

      That is all I've done. What else do I need to do?