Home  >  Article  >  Java  >  c3p0 usage record in java

c3p0 usage record in java

怪我咯
怪我咯Original
2017-06-26 11:52:451390browse
  • 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>
    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;
    }
    }

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!

Statement:
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