1 Reply Latest reply on Aug 14, 2002 6:10 AM by Saif Khan

    accessing mysql/jboss3 from an ejb

    declan boylan Newbie

      Just wondering if i'm doing this the right way...

      First i copy the mysql-service.xml into the deploy folder from the doc/jca...

      Correct me if i 'm wrong, but if i am to add those extra lines to the login-conf.xml then i do not have to do a db call as follows...

      Class.forName("org.gjt.mm.mysql.Driver");
      dbConn = DriverManager.getConnection("jdbc:mysql://136.206.17.39/Vv","username","password");

      but as follows...
      Class.forName("org.gjt.mm.mysql.Driver");
      dbConn = DriverManager.getConnection("jdbc:mysql://136.206.17.39/Vv");

      Is there anything else i should know about connecting to a db?

        • 1. Re: accessing mysql/jboss3 from an ejb
          Saif Khan Newbie

          You are right to put a mysql-service.xml file in the deploy directory and change login-conf.xml. Rather
          than call the DB as you do, you can use:

          Context ctxt = new InitialContext();
          DataSource myDS = (DataSource)ctxt.lookup("java:jdbc/MySqlDS");
          Connection = myDS.getConnection();

          The reason for all that xml is so that you can refer to
          your db through a jndi name.