Tuesday, January 3, 2012

How to create Oracle DataSource in Glassfish

Oracle (previously Sun) Glassfish web server is really great Java EE open-source application server for small and midsize applications.

Glassfish is free, supports all Java EE API specifications, rich in features (JDBC, RMI, e-Mail, JMS, web services, JavaBeans, Connectors, servlets, portlets ..etc..)

At other hand, Glassfish has really easy to use and effective admin console, by default, you can access it from server IP address at port 4848:
http://127.0.0.1:4848/

At this post I'll describe a small thing about Glassfish for newbies, It's about how to make JDBC data source with Oracle database and how to use it at Java code.

First Login into Glassfish admin console, other steps are described clearly via images bellow:

1- Make new JDBC connection pool:


2- Select "java.sql.Driver" as resource type, also don't forget to select the driver vendor (Oracle at my case)






3-At step 2, fill the connection URL + user-name and password of your database connection:



4-Finally, access the new pool and make "Ping" enabled, ping at this case means check connection, If you got "Ping Succeeded" message that means you can obtain a connection with the database:


5-Now you have to create JDBC resource uses the pool that we just created:


6-Finished, all what you need now is to use this JDBC resource at your Java code as follow:


No comments:

Post a Comment