lunedì 3 gennaio 2011

Glassfish v3 + Derby DB configuration

I found a great tutorial on using Glassfish v3 with Eclipse at http://programming.manessinger.com/tutorials/an-eclipse-glassfish-java-ee-6-tutorial/ . Here I will summarize how to create a Derby DB in eclipse and how to configure connection pool and JDBC resources using the Glassfish Administration Console.

Before doing this make sure that the Glassfish preference Start the JavaDB database process when Starting GlassFish Server is ticked.

First we have to create the Derby Database, in eclipse is very simple. Go in Data Source Explorer tab and on the contextual menu of Database Connection select new. Now select Derby as Connection Profile Type and set the name of the database, for example ShortRental Database. 
Now in the next step set the database properties as in figure:



Now start the GlassFish server and connect to the administration console (the default port is 4860) and go to Resources / JDBC / Connection Pools. Now create a new Connection Pool. Set the parameters as in figure:

Now pass to the next step, leave the properties at bottom as they are, and set the advanced properties as in the Derby DB, see the next screenshot:


At this point the configuration is completed, make sure the Ping checkbox is enabled and now you can try to ping the database.

The last operation to do is to define a JNDI name for access the database. Go to Resources / JDBC / JDBC Resources, add a new one and connect it to the just cretaed pool.

Nessun commento: