Configure the WebLogic connection pool and data Source

Source: Internet
Author: User
Tags sql stmt table name zip
Connection|web
Os version:windwos2000 serverhostname:mytestdatabase:oracle 9.2.0.1port:1521table:test (a number (2)) User: Systempassword:oracleweblogic version:7.0.4domain:mydomainserver:myserverport:7001wl_home:d:\bea\ Weblogic1. Configure connection pool to open the WebLogic Management console [http://mytest:7001/console]mydomain->services->jdbc-> Connection pools adds a connection Poolname:OraThinpoolurl:jdbc:oracle:thin: @mytest: 1521:technetdriver Classname: Oracle.jdbc.driver.oracledriverproperties:user=systempassword:oracletarget:myservertest table name:dual2. Configuration data Source opens WebLogic Management console [Http://mytest:7001/console]mydomain->services->jdbc->data source adds a Data Sourcename:orathindsjndi name:jndi_orathindspool Name:OraThinPooltarget:myserver3. Test generation Code Context CTX = NULL; Hashtable ht = new Hashtable (); Ht.put (Context.initial_context_factory, "weblogic.jndi.WLInitialContextFactory"); Ht.put (Context.provider_url, "t3://mytest:7001"); try {ctx = new InitialContext (HT); Javax.sql.DataSource ds = ( Javax.sql.DataSource) Ctx.lookup ("Jndi_orathinds"); Java.sql.Connection conn = Ds.getconnection (); Statement stmt=conn.createstatement (); String sql= "Select a From Test"; ResultSet rs=stmt.executequery (SQL) while (Rs.next ()) {int i=rs.getint (1); System.out.println (i);}} catch (Exception e) {e.printstacktrace ();} Rs.close (); Stmt.close (); Conn.close (); 4. Note the JDBC driver position in the library should be present in the environment change classpath, this example uses the drive classes12.zip in D:\bea\ WebLogic erver\lib classpath=d:\bea\weblogic erver\lib\classes12.zip;%classpath% modified d:\bea\weblogic Erver\bin Tartwls.cmd the classpath in the back of the WebLogic.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.