Sunday, October 28, 2007

Creating Oracle datasource in Glassfish

Sunday, October 28, 2007 Posted by Andre Broers , 13 comments
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.

13 comments:

  1. thx for the steps :D

    ReplyDelete
  2. Truly, this is crystal clear and so much helpful...

    THANKS....

    ReplyDelete
  3. I've still recieved an error. this is from my gfish server.log:
    [#|2009-11-02T10:47:39.112+0800|INFO|sun-glassfish|null|_ThreadID=16;_ThreadName=Thread-3;|- Could not find the dbase reference name|#]
    pls help me.. thankz!

    ReplyDelete
  4. nice work...
    it is working with ojdbc14.jar also...
    Thank...

    ReplyDelete
  5. nice work. helped me a lot thx

    ReplyDelete
  6. Great work. helped me a lot...

    Thanks...

    ReplyDelete