1. Click on "JDBC" under "Resources" on "Common Tasks" on the left hand side in the admin console of GlassFish.
2. Click on "Connection Pools" on the right pane.
3. Click on the "New" button.
4. Enter a name for the connection pool, select Resource Type: javax.sql.DataS ource, select Database Vendor: Oracle
5. Delete all properties, and add following properties:
- user - set this to Oracle userid
- password - set this to Oracle password
- URL - set this to the URL, example jdbc:oracle:thi
n:@localhost:15 21:DATABASENAME
6. Save the connection pool.
7. Now, create a new JDBC Resource, which will have a JNDI name to which your application will refer to.
8. Configuration settings required in the web.xml file and sun-web.xml:
- unlike tomcat you wont need a \META-INF\conte
xt.xml file. - configure the JNDI for your application in web.xml, following is an example:
- <resource-re
f>
<res-ref-name>jdbc/Oracl eTest</res-r ef-name>
<res-type>javax.sql.Data Source</res- type>
<res-auth>Container</ res-auth>
<res-sharing-scope>Share able</res-sh aring-scope>
</resource-ref> - configuration for sun-web.xml:
- <resource-re
f>
<res-ref-name>jdbc/Oracl eTest</res-r ef-name>
<jndi-name>jdbc/OracleTe st</jndi-nam e>
</resource-ref>
jdbc/OracleTest is the JNDI name configured for the Connection Pool that we have created above in the admin colsole of GlassFish.
You can now use java:comp/env/j dbc/OracleTest for look up and connect to the database.
2 comments:
EXCELENT THANKS
Usefull information! blesses..
Post a Comment