Sunday, January 06, 2008

Alright, here are my notes on all of this.

First, much of the documentation out there on the web I saw had plenty of JPA for J2SE examples. Nothing I found talked about the setup of the glassfish data pools and sources.

<jta-data-source>jdbc/MySQL</jta-data-source>


Shows the configuration for the persistence.xml you'll need to include. This should be part of the <persistence-unit> tag that you'll include as part of persistence.xml. EJB3 users should know how to set this up or can easily reference this.



That's about the only real configuration you'll need as part of your persistence.xml file for the Glassfish server to locate your connection.



The rest is in glassfish. Why the Apress EJB3 book does include this information is beyond me. It's like a whole chapter on setting up the data sources is needed.



In glassfish login and go to your connection pools for JDBC



From here you'll need to create a new connection pool. Configure the connection as a javax.sql.DataSource then use the Database Vendor MySQL. You'll also need to give it a name. Save your new connection pool, then go back into it to make the following modifications under "Additional Properties" tab.

Under the advanced properties tab, you'll need to create a 'user' property and give it the user name. This would be whatever the mysql login is. Since I was using my research server I simply used 'root'. I didn't have to specify a 'password' property, but I imagine you'll need to in an actual configuration on a live server.

From there you'll need to modify the URL properties (I noticed there were 2 different ones, so I modified both to match). This should be something like 'jdbc:mysql://localhost/XE' where XE is the database you're attempting to access.

Now go back into the JDBC settings and go to JDBC resources. This is where you want to give it a name which matches the jta tag above. create a new JDBC resource that points to the connection pool you just created.

I found it necessary to restart Glassfish here. Although not every change here requires a glassfish restart technically. In practice I couldn't get it to work without the restart.

That was it, once that is setup you should be able to have your client access the localhost for the proper database connection which is mysql and not derby.
Comments:
Thank you for the describing what you did! It was the last piece I needed for getting all the same pieces to work together. I find it strange that so much fiddling is necessary to get MySQL working with GlassFish, and it was frustrating hunting around the web for the info.
 
Post a Comment

Links to this post:

Create a Link

<< Home


Recent Posts


EJB3, Glassfish, MySQL, Toplink Working Together
Google Mapplets and Custom Writeable Pushpins
Well this blog has been fairly inactive since I've...
Starting EJB Certification
Passed SCJP 1.5
SCJP Exam
Test From Brainbench
Java code snippet for ODBC connections.
SCJP Study continues
Rob's Timers


Archives

01/01/2005 - 02/01/2005
02/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
04/01/2006 - 05/01/2006
05/01/2006 - 06/01/2006
09/01/2006 - 10/01/2006
10/01/2006 - 11/01/2006
11/01/2006 - 12/01/2006
12/01/2006 - 01/01/2007
04/01/2007 - 05/01/2007
05/01/2007 - 06/01/2007
01/01/2008 - 02/01/2008
02/01/2008 - 03/01/2008
05/01/2008 - 06/01/2008
06/01/2008 - 07/01/2008
08/01/2008 - 09/01/2008
09/01/2008 - 10/01/2008
11/01/2008 - 12/01/2008
12/01/2008 - 01/01/2009
01/01/2009 - 02/01/2009
02/01/2009 - 03/01/2009
04/01/2009 - 05/01/2009
05/01/2009 - 06/01/2009
07/01/2009 - 08/01/2009
01/01/2010 - 02/01/2010

My Software

Blinky - GBPVR Plugin
PhotoCopy - GBPVR Plugin
QTC - Quick Test Case
rBoop - Rob's Timers

Programming Links

C# Formatter
NSIS

Other Links

Damn Small Linux

Sites I Manage

Do it yourself SEO. Cheap.
Pet Supplies
Dog toy of the month club
SqueakerZ pet Deals
Geocaching Community
Hitch hiker Tracking