Having J2EE use mySQL
Hi
I'm using a standalone RedHat 9 system with J2EE 1.3.1 and mySQL 3.23.54.
All are working individually.
My current application creates new tables every time it starts, so I thought it would be dead simple to just ask J2EE to use mySQL. There are currently only two entity beans, and there's the place in the deploytool to enter the database JNDI name, username and password.
I can't find any information on how to do it though. What do I enter where? Sun's site doesn't seem to tell me about mySQL and J2EE, while mySQL has not one mention of J2EE in its documentation, nor in Kofler (my mySQL book).
I looked back through this forum too, and there's a link to a blog that doesn't seem relevant either.
Clues anyone? Much appreciated. If I see you, I'll buy you a pint. Warm, obviously (I'm in the UK). You'll like it, honest :-)
J
You have to register the JDBC driver of the database to the application server AND create the JNDI entry corresponding to that dB.
Refer to the Configuration guide bundled with the J2EE 1.3.1 RI documentation.
In general you will use the j2eeadmin tool
You can search for the topic JDBC drivers in the configuration guide
Hi! I think I may help you. I had the same problem. But I磎 Brazilian, I磎 learning the English language yet. I磍l try to explain you.
I am using J2EE version 1.3 with MySQL version 4.1.7 on Windows. You磍l have to configure the two following files:
- <J2EE_HOME>\bin\setenv.bat
- <J2EE_HOME>\config\resource.properties
1) Copy the Jar file of MySQL driver to <J2EE_HOME>\lib directory.
2) Open the setenv.bat and edit it. Add a reference to that Jar file.
3) Run the <J2EE_HOME>\bin\j2eeadmin.bat. There are two command lines to be executed, as below:
j2eeadmin.bat -addJdbcDriver <CLASS NAME OF THE DRIVER>
j2eeadmin.bat -addJdbcDatasource <JNDI-NAME> <URL>
For example:
j2eeadmin.bat -addJdbcDriver "com.mysql.jdbc.Driver"
j2eeadmin.bat -addJdbcDatasource "jdbc/mysql-connection/test" "jdbc:mysql://localhost/test?user=username&password=password"
4) Now, the <J2EE_HOME>\config\resource.properties must be modified, with the reference for the MySQL database. Open this file and you will see. But perhaps you will have to configure it editing this file. That磗 because I noticed that the character "\" was added erroneously in a lot of places of the code of this file. It seems to be a bug. So I simply removed this character, replacing it.
5) Run the verbose, none error must appear, and the MySQL can be used with J2EE now! That磗 all. Good luck!