Home > Java > javaTutorial > body text

c3p0 usage record in java

怪我咯
Release: 2017-06-26 11:52:45
Original
1383 people have browsed it
  • First of all, you need to import the c3p0 package.c3p0After downloading and decompressing, there are three packages in the lib directory, use mysql If , you only need to import c3p0-0.9.5.2.jar,mchange-commons-java-0.2.11.jar.

  • ##To connect to the

    mysql database, you need to import mysql-connector-java-5.1.42-bin.jar.

  • For convenience To operate the database link for query, you need to import

    commons-dbutils-1.6.jar,commons-collections-3.2.2.jar,commons-logging-1.2.jar.

  • ##In order to make
  • c3p0

    easy to maintain, c3p0-config.xml

    <?xml version="1.0" encoding="UTF-8"?><c3p0-config>
      <default-config><property name="user">root</property><property name="password">root</property><property name="jdbcUrl">jdbc:mysql://127.0.0.1:3306/day20</property><property name="driverClass">com.mysql.jdbc.Driver</property>
      </default-config></c3p0-config>
    Copy after login
    needs to be created in the src directory

  • Use
  • c3p0

    import javax.sql.DataSource;import com.mchange.v2.c3p0.ComboPooledDataSource;public class JdbcUtils {private static ComboPooledDataSource ds;static {
        ds = new ComboPooledDataSource();
    }public static DataSource getDataSource(){return ds;
    }
    }
    Copy after login

The above is the detailed content of c3p0 usage record in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!