c3p0连接数据库
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<!-- 最多可以创建多少个statement -->
<!-- 最多可以创建多少个statement -->
<property name="maxStatements">50</property>
<!-- 最多有多少个连接 -->
<property name="maxPoolSize">4</property>
<property name="initialPoolSize">2</property>
<property name="acquireIncrement">2</property>
<property name="minPoolSize">2</property>
<!-- 连接的超时间 -->
<property name="checkoutTimeout">3000</property>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql:///abc
</property>
<property name="user">root</property>
<property name="password">1234</property>
</default-config> <!-- 配置其他的连接,用户的其他配置可以有多个 --> <named-config name="jtedu"> <property name="maxStatements">50</property>
<!-- 最多有多少个连接 -->
<property name="maxPoolSize">4</property>
<property name="initialPoolSize">2</property>
<property name="acquireIncrement">2</property>
<property name="minPoolSize">2</property>
<!-- 连接的超时间 -->
<property name="checkoutTimeout">3000</property>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql:///abc
</property>
<property name="user">root</property>
<property name="password">1234</property>
</named-config>
</c3p0-config>
package c3p0连接池;
import java.sql.Connection;
import javax.sql.DataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class c3p0Utiles {
// public static void main(String[] args) {
// System.err.println(c3p0Utiles.getCon());
//
// }
private static DataSource ds;
static {
//默认配置
ds = new ComboPooledDataSource();
//指定配置
//ds=new ComboPooledDataSource("jteud");
}
public static DataSource getDs() {
return ds;
}
public static Connection getCon() {
Connection con = null;
try {
con = ds.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
}
c3p0连接数据库的更多相关文章
- c3p0连接数据库的3种方式
c3p0连接数据库的3种方式,这里以mysql为例 1. 直接用set方法设置参数, 基本方法 ComboPooledDataSource dataSource = new ComboPooledDa ...
- c3p0 连接数据库失败的问题
报错:java.sql.SQLException: No suitable driver 显然,这里c3p0由于没有找到对应的配置文件(c3p0-config.xml或者c3p0.properties ...
- JAVA通过C3P0连接数据库
配置文件: <?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <na ...
- Spring与C3p0连接数据库对事务操作
maven包: <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncodin ...
- dea创建Maven工程用c3p0连接数据库报错java.sql.SQLException: Connections could not be acquired from the underlying
idea java.sql.SQLException: Connections could not be acquired from the underlying database! 转载自:ht ...
- 数据库连接池技术,c3p0
百度 谷歌 http://commons.apache.org/ 可以找到DBCP , 这里选择使用C3P0,百度一下.https://www.mchange.com/projects/c ...
- Spring连接数据库
public class Book { private int bookid; private String bookname; private String bookauthor; private ...
- JavaWeb_(Hibernate框架)Hibernate与c3p0与Dbutils的区别
JavaWeb_(Hibernate框架)使用Hibernate开发用户注册功能 传送门 JavaWeb_(Hibernate框架)使用c3p0与Dbutils开发用户注册功能 传送门 Hiberna ...
- jquery+ajax+struts2
AJAX 是与服务器交换数据的艺术,它在不重载全部页面的情况下,实现了对部分网页的更新.编写常规的 AJAX 代码并不容易,因为不同的浏览器对 AJAX 的实现并不相同.这意味着您必须编写额外的代码对 ...
随机推荐
- PowerDesigner使用常见问题
1.在数据库生成表的时候,要求PowerDesigner中设计的表的Name的值要放到数据库中表的描述中,而不是PowerDesigner 中字段的Comment: 具体方法如下:首先将PowerDe ...
- 将实体转成XML,XML节点顺序由我控制
一.前言 由于有时候返回xml格式比较严格,需要按照一定的顺序排列节点才能够符合要求,这里主要用到了自定义一个List<string> 字符顺序,再让实体属性按照List定义好的顺序重新排 ...
- hdu Counting Sheepsuanga
算法:深搜 题意:让你判断一共有几个羊圈: 思路:像四个方向搜索: Problem Description A while ago I had trouble sleeping. I used to ...
- winPcap_2_编译环境*注意*
使用WinPcap编程 创建一个使用 wpcap.dll 的应用程序 用 Microsoft Visual C++ 创建一个使用 wpcap.dll 的应用程序,需要按以下步骤: 在每一个使用了库的源 ...
- jquery dataTable 入门
step1:切记要先引入jquery <link rel="stylesheet" type="text/css" href="C:\Users ...
- C语言float型数据在内存中的储存方式
- Linux - How To Set Up an NFS Mount on CentOS 6
About NFS (Network File System) Mounts NFS mounts work to share a directory between several servers. ...
- NSArray和NSMutableArray相互转换, 以及常用方法-备
有时候项目中NSArray和NSMutableArray需要相互转化,下面给出相关代码1.NSArray 1.1 转化:NSMutableArray 1 NSMutableArray *mutable ...
- 对163k地方门户网站系统QQ互联功能修改
163k地方门户网站QQ互联申请时遇到的问题: "禁止开发商强制用户重新注册或绑定其他帐号" 原因是用户登录完QQ还需要注册帐号或者绑定原有帐号 163k地方门户网站的QQ互联登录 ...
- ps2keyboard demo code for 8052
#pragma code symbols debug objectextend #include <reg51.h> /* special function register declar ...