Fast + Convenient Way To Create Glassfish v3/v2 Connection Pools / Data Sources

With Glassfish v2/v3 you can create a connection pool and data sources manually, by:

  • Copying the JDBC-driver jar into [GLASSFISH_HOME]/domains/(domain1)/lib
  • Setting up a connection pool and data source using the asadmin, web console, RESTful interface (v3) or editing the domain.xml file.

In Netbeans (6.7/6.8) the connection pools and datasources can directly deployed from the IDE. You can just "reuse" existing connection from the "services" tab, or create new one:

  1. Click on Databases -> Drivers  and choose "New Driver".
  2. Point to an existing JDBC driver jar.
  3. Click on Databases -> New Connection and select your freshly created driver

After this step you will be able to connect the database, browse the tables and execute SQL-statements. Its convenient for development.

If you want to deploy a JDBC connection with your app, then:

  1. Click on your project (WAR, EJB) and choose New -> Other -> Glassfish -> Connection Pool
  2. Select your existing or freshly created connection - all the data will be extracted.
  3. Repeat Step 1. choosing a DataSource
  4. DataSource and ConnectionPools should appear in Tab "Services" -> Servers -> Glassfish -> Resources -> JDBC -> JDBC Resources
At the next deployment the connection, together with the JDBC-driver will be installed on the Glassfish. Now you can refer to the the newly created in e.g. persistence.xml.  I tested it with Glassfish v2 and v3.

Comments:

Gutentag Adam,
Please forgive me as I butcher the German. I've seen many, many examples of how to set these up, but there's hardly anything on how to reference them once they are. Can you please give me an example?

Danke!
Scott

Posted by Scott on January 15, 2010 at 02:16 AM CET #

THANK YOU!

Posted by Aaron on July 26, 2010 at 11:59 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License