Adam Bien's Weblog

Saturday Aug 15, 2009

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.


[my tweets]  Rss My book: Real World Java EE - Rethinking Best Practices

Kommentare:

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

Gesendet von Scott am January 15, 2010 at 01:16 AM CET #

THANK YOU!

Gesendet von Aaron am July 26, 2010 at 09:59 PM CEST #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
Meta-stuff / Interviews
My Recent Book
Java One 2009
CommunityOne East N.Y.C
JavaONE 2008 Interview
Search
...the last 150 posts
...the last 10 comments
greenfire.dev.java.net
Links
my.netbeans.org
Visitors
License