Using Proxool__java in Java projects

Source: Internet
Author: User

The Proxool Getting started instance that you found on the Internet is used in Web projects

The following example is a simple Java project that uses Proxool.

To sum up, in fact, it is also very simple is to proxool.xml loaded in the method is not the same


The required jar files are:

Classes12-10.0.2.jar

Commons-logging-1.0.4.jar

Proxool-0.9.1.jar

Proxool-cglib-0.9.1.jar


Related Resources Download: http://download.csdn.net/detail/xswd169/6366947


The code is as follows:


Testproxool

Package com.leader.proxool;

Import Org.logicalcobwebs.proxool.configuration.JAXPConfigurator;
Import java.sql.Connection;
Import Java.sql.DriverManager;
Import Java.sql.ResultSet;

Import java.sql.Statement;
 /** * Created by the IntelliJ idea. * * @author leizhimin 2009-10-10 17:59:47/public class Testproxool {public static String Dburl = "Jdbc:oracle:thin
	: @192.168.104.192:1521:tim ";
	public static String user = "Tim";

	public static String password = "tim_8968888";  /** * JDBC Mode test * * @throws Exception/public static void Test1 () throws Exception {String testsql = "Select
		* from village t where LastID = 346 ";
		1: Registered Driver class Class.forName ("Oracle.jdbc.driver.OracleDriver");
		2: Create DATABASE connection Connection conn = drivermanager.getconnection (dburl, user, password);
		3: Create an object to execute SQL Statement stmt = conn.createstatement ();
		4: Execute SQL, and get return result ResultSet rs = stmt.executequery (testsql); 5: Processing returns results, where the query results are printed while (Rs.next ()) {System.out.print (Rs.getlong) ("ID") +" T ");
			System.out.print (rs.getstring ("name") + "T");
		System.out.println ();
	}//6: Close database connection conn.close (); /** * Proxool Mode Test * * @throws Exception/public static void Test2 () throws Exception {//Java applications to load the configuration text first
		
		Pieces, or who knows who you are configured to use for Jaxpconfigurator. Configure ("E:\\eclipsenew\\eclipse\\workspace\\proxool\\proxool.xml", false);
		
		String testsql = "SELECT * from Dest_poi";
		1: Register the Drive class, this time this drive is not Oracle's drive, is the Proxool dedicated drive Class.forName ("Org.logicalcobwebs.proxool.ProxoolDriver"); 2: Create the database connection, this parameter is a string, is the alias of the data source, the Timalias configured in the configuration file, the parameter format is: Proxool. The alias of the data source Connection conn = Drivermanager.getconnection ("Proxool.")
		
		");
		3: Create an object to execute SQL Statement stmt = conn.createstatement ();
		
		4: Execute SQL, and get return result ResultSet rs = stmt.executequery (testsql);
			5: Processing returns results, where the query results are printed while (Rs.next ()) {System.out.print (Rs.getlong ("id") + "T");
			System.out.print (rs.getstring ("dest_name") + "T");
		System.out.println ();
}//6: Close database connection conn.close ();	/** * Test * @param args * @throws Exception/public static void main (string[] args) throws Exception {T
	Est2 (); }
}

Proxool.xml

<?xml version= "1.0" encoding= "UTF-8"?> <something-else-entirely> <proxool> <a Lias>first</alias> <!--aliases for data sources--> <driver-url>jdbc:oracle:thin:@10.10.10 .4:1521:orcl</driver-url> <!--URL connection string--> <driver-class>oracle.jdbc.driver .
                		oracledriver</driver-class> <!--Drive class--> <driver-properties> <!--username--> <property name= "user" value= "tcar1"/> <!--password--> <prope Rty name= "Password" value= "tcar_cityonmap2012"/> </driver-properties> <!--Max Company Number of connections (default 5), more than the number of this connection, and then request, queued in the queue, the largest number of waiting requests by maximum-new-connections decision--> <maximum-connection-count&gt ;100</maximum-connection-count> <!--minimum number of connections (default 2)--> <minimum-connection-coun T>10</minimum-connection-count> <!--Proxool automatically detects the time interval (milliseconds) of each connection state, reclaims the idle connection immediately, and then destroys the default 30 seconds-->  





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.