CONFIGURATION CONNECTION
POOL AND
DATA SOURCE
IN WEBLOGIC8.1 SERVER
Step1: create the domain (context). Start programs Bea web logic configuration wizard Graphically create the domain
Step2: to which database we want to connect, corresponding jar file place in the following location E:\bea\weblogic81\server\lib Example: clasess12.jar (for oracle9.0) Step3: Start web logic server Start programs Bea web logic User project (given domain name) start server Step4: login to web logic server using graphical tool web logic server admin console Type the following URL into the browser. http://localhost:7001/console Step5: configure the connection pool In the tree structure of the admine console Services JDBC Connection pool
Configuration
Configure a new JDBC Connection Pool...
Select above link, and then find the following
Database Type:
Oracle
//select your database
Database Driver: -------------- //select the data base
Then select Next:
continue
Name: MyJDBC
Connection Pool Driver Classname: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:thin:@localhost:1521:server
// here server is the service name of the database, to know the service name we should search in database with the name tnsname.ora. In that file we have to find the service name. For example server is the service name of oracle90, xe is the service name of oracle10g
Database User Name: scott Password: tiger Confirm Password: tiger Properties: ----------------
Select Continue Create and deploy .. Connection pool created. <Check on server console> Note: if every thing goes well weblogic server creates 15-25 database connections and keeps in catch memory.
Step6: configure Data source Services JDBC data source configure a new JDBC resource. Enter JNDI name: ourds (any name) --- continue Pool name: My JDBC connection pool -continue create
Note: if every thing goes well data source objects (implementation class of javax.sql.DataSource) created and registered with JNDI name in service with the name ourds(with given JNDI name).
Get a pooled connection in a java application.
To get the pooled connection in a java application we have the following steps. Step1: connect to the JNDI naming service running within application server process. InitialContext ic=new InitialContext(p); Step2: perform lookup for the data source object by supplying the JNDI name. DataSource ds=(DataSource)ic.lookup(ourds); Step3: calling getConnection() method on DataSource object and gets the connection. Connection con=ds.getConnection();