users@glassfish.java.net

setting up connection pool, resource, and persistence unit

From: Bobby Bissett <Robert.Bissett_at_Sun.COM>
Date: Thu, 14 Jan 2010 10:20:50 -0500

[new subject for users_at_gf list in case this info is useful for others]
>>
>> If you need a full example of creating the database
>> connection pool,
>> jndi resource, and then how to connect it to your
>> persistence.xml
>> file, let me know. I just happen to have some
>> screenshots on my
>> desktop that I have as reminders.
>
> I'll take you up on that. I've only done it once under v2.1.

Sure thing. See attached (if they get lost in the process I'll put
them somewhere with links). The first two images (step1 and step2)
show what you do under Resources -> JDBC -> Connection Pools -> New.
That's all the data I entered, total. In this case I'm using Derby
(JavaDB) that comes with GFv3. With the "create=true" property, the DB
will automatically be created for you when needed, so you don't have
to do any database setup ahead of time. The database name, user, and
password are of course all arbitrary.

The 3rd image shows what you do under Resources -> JDBC -> JDBC
Resources -> New. Just select the pool you created already and give it
a JNDI name. This same name is what you have in your persistence.xml
file. In my case, the whole file is:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" ...........>
   <persistence-unit name="ee6v_PU" transaction-type="JTA">
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</
provider>
     <jta-data-source>jdbc/EE6Vaadin</jta-data-source>
     <properties>
       <!-- For demo purposes, we'll just let JPA create the tables.
            Feel free to comment this out after deploying the first
time. -->
       <!--<property name="eclipselink.ddl-generation" value="create-
tables"/>-->
     </properties>
   </persistence-unit>
</persistence>

As you can see, I commented out the create-tables prop after the 1st
time I deployed.

Cheers,
Bobby






step1.png
(image/png attachment: step1.png)

step2.png
(image/png attachment: step2.png)

step3.png
(image/png attachment: step3.png)