Java C3P0 Connection Pool

Source: Internet
Author: User

Importjava.beans.PropertyVetoException;Importjava.sql.Connection;Importjava.sql.SQLException;ImportJavax.sql.ConnectionPoolDataSource;Importjavax.swing.text.DefaultEditorKit.InsertBreakAction;ImportCom.mchange.v2.c3p0.ComboPooledDataSource; Public classConnectData { Public Static voidMain (string[] args) {System.out.println (connectdata.getconnection ()); }        Private StaticString username= "LF"; Private StaticString password= "LF";  Public StaticConnection getconnection () {//Create a connection poolCombopooleddatasource DataSource =NewCombopooleddatasource (); //by mapping to drive        Try{Datasource.setdriverclass ("Oracle.jdbc.driver.OracleDriver"); } Catch(propertyvetoexception e) {e.printstacktrace (); }        //Set URLDatasource.setjdbcurl ("JDBC:ORACLE:THIN:@192.168.10.105:1521:ORCL"); //set up Database user accountDatasource.setuser (userName); //Set Database PasswordDatasource.setpassword (password); Datasource.setinitialpoolsize (5); Datasource.setmaxpoolsize (13); Datasource.setminpoolsize (3); Try {            //Get Connections            returndatasource.getconnection (); } Catch(SQLException e) {e.printstacktrace (); }        return NULL; }}

Java C3P0 Connection Pool

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.