1 Reply Latest reply on Nov 22, 2003 10:06 PM by danb99

    MySQL Datasource

    danb99

      I am trying to set up a Datasource in jboss for MySql, but am getting an exception on the ctx.lookup. Can anyone point out what else I need to do? The exception is 'Receive timed out'. Thanks!

      This is the code I have for getting the DataSource:

      try {
      Context ctx;
      Properties prop = new Properties();
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      prop.put( Context.PROVIDER_URL, "Pendjari:1099" );
      prop.put( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      ctx = new InitialContext( prop );
      DataSource ds = (DataSource)ctx.lookup("MySqlDS");
      Connection con = ds.getConnection("user", "pwd");
      } catch( Exception e ) {
      System.out.println(e.getMessage());
      }

      And this is the mysql-ds.xml file in the jboss deploy directory:



      <local-tx-datasource>
      <jndi-name>MySqlDS</jndi-name>
      <connection-url>jdbc:mysql://127.0.0.1:3306</connection-url>
      <driver-class>org.gjt.mm.mysql.Driver</driver-class>
      <user-name></user-name>

      </local-tx-datasource>

        • 1. Re: MySQL Datasource
          danb99

          Dan, make sure you are not creating the Datasource in a client. You must be within the App Server to create a Datasource. Try creating your Datasource in a Servlet - that should work.