1 Reply Latest reply on Apr 6, 2004 11:07 AM by captrespect

    Mysql 5.1 datasource problems

    captrespect

      We are trying to migrate our sql server database to mysql 5. I can't seem to get a datasource from the mysql 5 connection in my servlets. I can connect to the database by not using dbcp and using the connection string and I can get a datasource from MS Sql Server. Has anyone been about to do this or is it a problem with mysql 5 alpha?

      using Jboss 3.2.3, suse 9, mysql 5.0.0
      tried with connect/j 3.0.11 and connect/j 3.1.1-alpha

      Here's what I got:
      web.xml:

      <resource-ref>
       <res-ref-name>MySqlTest</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
      </resource-ref>
      

      jboss-web.xml:
      <jboss-web>
       <resource-ref>
       <res-ref-name>MySqlTest</res-ref-name>
       <jndi-name>java:/MySqlTest</jndi-name>
       </resource-ref>
      </jboss-web>
      

      -ds.xml:
      <datasources>
       <local-tx-datasource>
       <jndi-name>MySqlTest</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/TestDB</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>test</user-name>
       <password>test</password>
       <min-pool-size>20</min-pool-size>
       <max-pool-size>300</max-pool-size>
       <idle-timeout-millis>10000</idle-timeout-millis>
       </local-tx-datasource>
      </datasources>
      

      failing servlet code:
       Context init = new InitialContext();
       Context ctx = (Context) init.lookup("java:comp/env");
       ds = (DataSource) ctx.lookup("MySqlTest");
      
       con = ds.getConnection(); //throws exception here
      


      and finally the exception:
      11:26:08,315 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection:
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException)
       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:160)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:477)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:213)
       at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:496)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:425)
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:318)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:477)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
       at test.DBConnection_Beta.setConnection(DBConnection_Beta.java:77)
      


      Thanks,

        • 1. Re: Mysql 5.1 datasource problems
          captrespect

          Nevermind. I solved this one already. On a hunch I removed my ms sql server jdbc driver, thinking they may be conflicting. Now It works fine.

          Can you use multiable types of databases at the same time? Or is this just an error in the driver?