Sunday, October 28, 2007

Creating Oracle datasource in Glassfish

Sunday, October 28, 2007 Posted by Andre Broers ,
Glassfish doesn't include the oracle drivers out of the box. To use these you need a jar file from oracle. You can download it from:

http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_111060.html

I used ojdbc6.jar. Copied the file to <glassfish>/lib directory and restart the the server:

asadmin stop-domain domain1

asadmin start-domain domain1

After this a connection pool must be created.

Login to the admin console of glassfish. Open the resources - JDBC - Connection Pools and select new.

Fill in the connection pool name, select javax.sql.ConnectionPoolDataSource and Oracle and click next..

Fill in the properties user, password en url (jdbc:oracle:thin:@<hostname>:<port>:<sid>

Click ping to test the connection.

When OK create a JDBC resource with JNDIName in the form of jdbc/<sid> and select the just created resource.

Now the connection can be used in your JPA classes.