Saving Glassfish JDBC Configuration

Go To StackoverFlow.com

0

I recently had to re-install Glassfish 3.1.2 from scratch and I found myself spending way too much time re-configuring the JDBC Connection Pools and Resources (copy/paste from another source was not an option). Many applications use the server and there are plenty of things to remember when configuring JDBC connectivity.

Is there a way to "save" the Glassfish JDBC configuration to a file so that I can easily upload it to a new version of the server (or a new server in another machine) without loosing my sanity again? A quick hack would also be highly appreciated as well!

2012-04-04 18:33
by Gevorg


2

Server scoped application resources are stored in the domain.xml file within the <resources> element. There are <jdbc-resource> and <jdbc-connection-pool> elements which store your connections. From my experience you can copy those elements from one domain.xml file to another (at least for all 3.x versions of Glassfish).

Application scoped resources can be stored in glassfish-resources.xml files which need to go into the META-INF dir for an EAR and in WEB-INF for a WAR. They will be deployed together with an application and can only be accessed by this application. More information here.

2012-04-04 20:01
by Matt Handy
I am using embedded glassfish and modified the domain.xml as you said but when I use '@Resource' for jdbc connections the look up fails. I have posted a question regarding this over here http://stackoverflow.com/questions/11824478/failed-to-inject-datasource-using-resource-in-ejb3-0-embedded-glassfish Can you please hel - Patton 2012-08-06 11:25
Just to add to this, while you can use glassfish-resources.xml to add application-scoped resources like the answer suggests, I think you can also use it to add server-scoped resources using asadmin add-resources glassfish-resources.xml - DavidS 2017-07-06 20:28
Ads