12 Replies Latest reply on Apr 17, 2002 3:07 AM by jgremmen

    MySQL

    gudujarlson

      Can someone point me to a HOWTO document on how to configure jboss to use MySQL (or other RDBMS)? I searched these forums and found some posts concerning this, but they contained stale links. I also found an example mysql-service.xml file in the documenation, but nothing explaining what to do with said file.

      Mike

        • 1. Re: MySQL
          sgwbutcher

          I'll second that request. I read Chapter 3 of the on-line documentation but the directions are for JBoss 3.x.

          Can someone give me a pointer a HOWTO for using mySQL with JBoss 2.4.4 which I gather amounts to modifying the contents of <!-- JDBC --> in jboss.jcml?

          Thank you,
          Steve

          • 2. Re: MySQL
            hubs2121

            For 3.0 simply drop the mysql-service.xml file into the deploy directory. By the way, you need version 1.1 of that file for the binary download version of JBoss3.0 and version 1.2 or whatever the latest is for the CVS version of 3.0.
            You can download these files from cvs, and if you do a search on the forums or on the mail list archives there is link mentioned somwhere to there exact location.

            Steve

            • 3. Re: MySQL
              ranger

              Hi Mike and Steve,

              there are a few entries in the jboss.jcml to configure JBoss using MySQL:

              1. Copy the mm.mysql-2.0.4-bin.jar to the %JBOSS_HOME%/lib/ext/ directory

              2. Add the following two mbean-tags to jboss.jcml:


              org.gjt.mm.mysql.Driver



              org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
              mySQLDS
              jdbc:mysql://host/databasename
              username
              password



              Don't forget to comment out the entries for the Hypersonic-SQL-Database...

              These config-example is taken from the JBoss-2.4.x documentation... Hope this will help you

              Greetings, Tobias

              • 4. Re: MySQL
                jtwomey

                For a detailed step by step tutorial on installing MySQL with JBoss go to the FAQ forum and look under the heading
                "Post your FAQ".

                Unfortunately no one has taken the time to move some of the helpful FAQ's listed here out into the "main" FAQ section. Only a select few may post directly to the "Main" FAQ forum.

                JT

                • 5. Re: MySQL
                  twobit

                  Hi everybody,

                  if one still can't get a mysql connection with the documented XADataSourceLoader Setup for mysql, check the mysql database and user setup.

                  mysql grants database access to users@hostname. If you set up a mysql user "you@yourhost", jboss possibly tries to connect to mysql as "you@yourhost.localdomain". It may help to grant permissions to this user.

                  Try to check the user with the mysql client:
                  $&gt; mysql -u you -ppassword -h yourhost -D databasename

                  If it still doesn't work, try to specify the mysql port number (i.e. an URL like "jdbc:mysql://host:3306/databasename").

                  To get the port, try
                  $&gt; mysqladmin variables

                  Greetings, Fritz

                  • 6. Re: MySQL
                    intach

                    <!-- ==================================================================== -->
                    <!-- my JDBC -->
                    <!-- ==================================================================== -->

                    org.gjt.mm.mysql.Driver



                    org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                    MySQLDS
                    jdbc:mysql://localhost:3306/jboss
                    sa


                    • 7. Re: MySQL
                      jgremmen

                      Please note that when MySQL is configured to allow access from 'every' host (grant to user@%) and your JBoss is running on the same host as your MySQL server, you have to grant access to the DB to user@localhost.
                      Obviously, the host wildcard (%) doesn't include localhost!

                      • 8. Configure several databases done with MySQL
                        martha_elva

                        Hi Ranger I read your post and it was very useful to me, THANKS A LOT, I tried with a mysql database and I think there wasn't any problem.

                        My question now, is what I have to do in order to configure 3 databases(done with mysql), they name: users, library and courses, I have to add their url, databasename, user, password etc..,, my doubt is how, do I need to repeat this part of the code 3 times, and is there any problem for the same port ?
                        This is the code segment I added in order to configure database users.


                        org.gjt.mm.mysql.Driver



                        DefaultDS
                        org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

                        jdbc:mysql://localhost:3306/users
                        <!-- jdbc:mysql://localhost:3306/MyDatabaseName -->
                        1200000
                        root
                        <!-- MyDataBaseUsername -->
                        password
                        <!-- MyDataBasePassword -->
                        10
                        false
                        false
                        false
                        true
                        120000
                        1800000
                        false
                        false
                        1.0
                        0

                        • 9. Re: MySQL
                          jgremmen

                          Hi Martha_elva,

                          To configure multiple databases you put the driver class for each database driver in the JdbcProvider MBean (seperated by commas), E.g.:


                          org.gjt.mm.mysql.Driver, oracle.jdbc.driver.OracleDriver


                          Then for each database connection you define a new DataSource MBean:


                          LibraryDS
                          org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                          jdbc:mysql://localhost:3306/library
                          library
                          jboss



                          CoursesDS
                          org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                          jdbc:mysql://localhost:3306/courses
                          courses
                          jboss



                          Hope this helps you out.

                          Please take a look at my post from 'Mar 21, 2002 8:11 AM' regarding localhost connections to MySQL.

                          • 10. Re: MySQL
                            martha_elva

                            Thank you jgremmen, I'll try it on.

                            • 11. Re: MySQL
                              thohawk

                              Hi jgremmen

                              Instead of having a connection pool for each account in Mysql, i just use the setCatalog-method in the Connection-object. Seems to work fine.....
                              Well, it was just another proposal :-)

                              Regards
                              Jesper

                              • 12. Re: MySQL
                                jgremmen

                                @thohawk,

                                that makes sense if you have a lot of different connections. I'm not that familiar with Jboss' internals but doesn't this technique influence transactions??Moreover, you are hardcoding database names in your java code, which might complicate testing.