3 de dez. de 2012

Configure Oracle jdbc Datasource into glassfish 3

To configure a new Oracle Jdbc Datasource into glassfish we have a 2 ways:

Pre-requisites:

    - Glassfish webserver 3.x
    - ojdbc6.jar (or another version) Click here to download it.

               Copy a jdbc driver to your application server and restart it:

                             copy ojdbc4dms.jar /myglassfishpath/domains/domain-1/lib
                             oasadmin restart-domain domain-1

    - Configured and working Oracle database with this informations:
              1) db usename = example: my_owner
              2) db password = example: my_oracle_password
              3) servername = example: mydatabaseip.mydomain.com
              4) databasename = example:my_database
              5) port: example 1523
              5) custom jdbc url: example: jdbc:oracle:thin:@mydatabaseip.mydomain.com:1521:my_database

Steps:

1- By glassfish web administrator:

         1.1 Open your glassfish web application and insert your admin and password:




             1.2 Resources / JDBC Connection Pools / NEW:


           1.3 Configure a new JDBC connection Poll, for example Oracle:






2- By command line:

     - To create a new datasource using asadmin:

asadmin> create-jdbc-connection-pool --restype javax.sql.DataSource 
--datasourceclassname oracle.jdbc.pool.OracleDataSource 
--property "user=myuser:password=mypass: url=jdbc\\:oracle\\:thin\\
:@example.mydatabase.url.service\\:1521\\:MyPool" MyPool 
(one line) 
 
JDBC connection pool Emp_Perks-Pool created successfully.
pmd-i1:
JDBC connection pool Emp_Perks-Pool created successfully.

pmd-i2:
JDBC connection pool Emp_Perks-Pool created successfully.

Command create-jdbc-connection-pool executed successfully.
 
 
   - Test your connection: 
 
       asadmin> ping-connection-pool MyPool
       Command ping-connection-pool executed successfully. 

More details from oracle http://docs.oracle.com/cd/E18930_01/html/821-2432/gkyan.html

Nenhum comentário:

Postar um comentário