All Packages  This Package 

Class examples.jdbc.datasource.simplesql



java.lang.Object


   |


   +----examples.jdbc.datasource.simplesql



public class simplesql
extends Object
This example demonstrates obtaining a database connection using a DataSource object.

This examples requires a running WebLogic Server and that you add the following entries to the weblogic.properties file.

To run this example:

  1. Set up your development shell as described in Setting up your environment.

  2. Add a DataSource object to the weblogic.properties file, which points to the myConnectionPool connection pool:
     weblogic.jdbc.DataSource.myNonJtsDataSource=myConnectionPool
  3. Next, define a connection pool in the weblogic.properties file. If you already have a pool configured to access your DBMS, change the "mypool" portion of the above entry to point to your connection pool. If you do not have a connection pool defined, modify the properties below by changing the url, driver and props line with the correct connection strings for connection to your DataBase. The example below uses an Oracle database.
     weblogic.jdbc.connectionPool.myConnectionPool=\
       url=jdbc:weblogic:oracle,\
       driver=weblogic.jdbc.oci.Driver,\
       loginDelaySecs=1,\
       initialCapacity=4,\
       maxCapacity=10,\
       capacityIncrement=2,\
       allowShrinking=true,\
       shrinkPeriodMins=15,\
       refreshMinutes=10,\
       testTable=dual,\
       allow=guest,\
       props=user=SCOTT;password=tiger;server=DEMO

    Note that the line "allow=guest" permits guest access to the connection pool. In a production environment, you should change this to match your security needs

  4. Change the line
      ht.put(Context.PROVIDER_URL,
               "t3://localhost:7001");
    substituting the name of the machine hosting your WebLogic Server for localhost and the port number at which the WebLogic Server is listening for connection requests for 7001

  5. Start your WebLogic Server

  6. Compile this example by executing the following command in your development shell:

    $ javac -d %CLIENT_CLASSES% simplesql.java

  7. Run this example by executing the following command in your development shell:

    $ java examples.jdbc.datasource.simplesql

*


Constructor Index

 o simplesql()

Method Index

 o main(String[])

Constructors

 o simplesql


 public simplesql()


Methods

 o main


 public static void main(String argv[]) throws Exception





All Packages  This Package g