2 Replies Latest reply on Aug 15, 2002 9:21 AM by davidjencks

    MySQL question/JBoss3 question...

    decob

      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: MySQL question/JBoss3 question...
          lucvu

          That's the idea. You can also add username and password in the mysql-service.xml itself.

          • 2. Re: MySQL question/JBoss3 question...
            davidjencks

            Whether you use the login-conf.xml setup or specify the user/pw in your mysql-service.xml file, you should be getting a connection like this:

            DataSource ds = (DataSource) new InitialContext().lookup("java:/mysqljndiname");
            Connection con = ds.getConnection();
            try {
            (do work)
            }
            finally {
            con.close();
            }

            where mysqljndiname is the jndi name you specified in mysql-service.xml

            Be sure you have the correct version mysql-service.xml file for your jboss version. There have been many small incompatible changes. One that came with a binary download should be ok for that version.