c3p0

logback日志输出至数据库

家住魔仙堡 提交于 2019-12-01 19:24:42
我们知道将数据库输出到不同的地方需要使用不同的appender表示,那下面了解一下输出到数据库的DBAppender。 1.DBAppender 由于DBAppender会把记录写到数据库中,因此我们必须知道数据库的结构。 1.根据官方文档创建数据库 DBAppender会把记录事件写入数据库的三张表(logging_event、logging_event_property、logging_event_exception),并且这三张表的结构是固定的。创建这三张表的脚本如下: BEGIN; DROP TABLE IF EXISTS logging_event_property; DROP TABLE IF EXISTS logging_event_exception; DROP TABLE IF EXISTS logging_event; COMMIT; BEGIN; CREATE TABLE logging_event ( timestmp BIGINT NOT NULL, formatted_message TEXT NOT NULL, logger_name VARCHAR(254) NOT NULL, level_string VARCHAR(254) NOT NULL, thread_name VARCHAR(254), reference_flag SMALLINT,

Database Connection to MySQL times out even after setting c3p0.testConnectionOnCheckout=true

删除回忆录丶 提交于 2019-12-01 19:13:36
问题 I have an app that uses hibernate (v3.6.4) , with connection pooling provided by C3P0 (v0.9.1.2) . The problem is I get a JDBC communications link failure if I make a DB query , if the app process ( and hence the C3P0 pool ) has been running for more time than the MySQL wait_timeout value. I set the value of wait_timeout in /etc/mysql/my.cnf to 600 seconds for testing this issue : 2013-01-27 20:08:00,088 ERROR [Thread-0] (JDBCExceptionReporter.java:234) - Communications link failure The last

Database Connection to MySQL times out even after setting c3p0.testConnectionOnCheckout=true

岁酱吖の 提交于 2019-12-01 19:00:06
I have an app that uses hibernate (v3.6.4) , with connection pooling provided by C3P0 (v0.9.1.2) . The problem is I get a JDBC communications link failure if I make a DB query , if the app process ( and hence the C3P0 pool ) has been running for more time than the MySQL wait_timeout value. I set the value of wait_timeout in /etc/mysql/my.cnf to 600 seconds for testing this issue : 2013-01-27 20:08:00,088 ERROR [Thread-0] (JDBCExceptionReporter.java:234) - Communications link failure The last packet successfully received from the server was 665,943 milliseconds ago. The last packet sent

Caused by: org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections

霸气de小男生 提交于 2019-12-01 18:53:36
I use c3p0-0.9.5.2.jar and mchange-commons-java-0.2.11.jar to manage the pool connection, And I use postgreSql 9.3. I get these messages at least once a day in my Prod environment : Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140) at org.springframework.orm

[转]c3p0学习-JdbcUtil工具类

ぃ、小莉子 提交于 2019-12-01 18:31:45
原文:https://www.cnblogs.com/jonny-xu/p/6374163.html 一、需要jar包:   c3p0-0.9.1.2.jar   mysql-connector-java-5.1.20-bin.jar 二、Java代码:    package com.javaweb.jdbc; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import com.mchange.v2.c3p0.ComboPooledDataSource; public class JdbcUtil { // 饿汉式 private static DataSource ds = new ComboPooledDataSource(); /*ThreadLocal * 它为null表示没有事务 * 它不为null表示有事务 * 当事物开始时,需要给它赋值 * 当事务结束时,需要给它赋值null * 并且在开启事务时,让dao的多个方法共享这个Connection */ private static ThreadLocal<Connection> tl = new ThreadLocal<Connection>(); public static

createArrayOf AbstractMethodError

做~自己de王妃 提交于 2019-12-01 17:41:17
问题 I am trying to insert an array to postgres using java code , but I always get this error : SEVERE [http-nio-8080-exec-2]org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [] in context with path [/] threw exception [Servlet execution threw an exception] with root cause java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array; Code Used pst = getConnection().prepareStatement

spring下配置dbcp,c3p0,proxool

旧街凉风 提交于 2019-12-01 17:37:42
不管通过何种持久化技术,都必须通过数据连接访问数据库,在Spring中,数据连接是通过数据源获得的。在以往的应用中,数据源一般 是Web应用服务器提供的。在Spring中,你不但可以通过JNDI获取应用服务器的数据源,也可以直接在Spring容器中配置数据源,此外,你还可 以通过代码的方式创建一个数据源,以便进行无依赖的单元测试 配置一个数据源 Spring在第三方依赖包中包含了两个数据源的实现类包,其一是Apache的DBCP,其二是 C3P0。可以在Spring配置文件中利用这两者中任何一个配置数据源。 DBCP数据源 DBCP类包位于 /lib/jakarta-commons/commons-dbcp.jar,DBCP是一个依赖 Jakarta commons-pool对象池机制的数据库连接池,所以在类路径下还必须包括/lib/jakarta- commons/commons-pool.jar。下面是使用DBCP配置MySql数据源的配置片断: xml 代码 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" />

Spring配置数据源的常用方式

こ雲淡風輕ζ 提交于 2019-12-01 17:37:20
Spring配置数据源的常用方式 在应用程序中配置数据源 (1).在classpath中创建连接参数的配置文件,如db-config.properties,内容如下: driverClass=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/zzp username=root password=admin (2).在Spring的配置文件中引入参数配置文件,代码如下: <!-- 配置spring资源文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>/WEB-INF/config/db-config.properties</value> </list> </property> </bean> (3).配置数据源(这里有三种方式,jdbc、dbcp、c3p0) A.JDBC的配置方式,该方式区别与其他两种方式在于这种方式使用的是JDBC连接数据库,并没有使用连接池,所以效率和性能方面不及其他两种,该种方式的配置方法: <!-- 数据源 --> <bean id=

数据库连接池DBCP和C3P0的使用

主宰稳场 提交于 2019-12-01 17:36:02
hibernate开发组推荐使用c3p0; spring开发组推荐使用dbcp; hibernate in action推荐使用c3p0; 一. dbcp 在数据库服务器 强行关闭连接或数据库服务重启后,无法reconnect 二. dbcp 连接池的创建速度优于c3p0,而c3p0的性能更加稳定 三. mysql8小时问题的解决方式不同: 众所周知,mysql在使用过程中,一个连接在8小时内无任何操作时,该连接会被断开,而连接池中的连接并不会感知该断开操作。dbcp和c3p0给出了不同的解决方案: dbcp需要添加两个配置参数: <set-property property="testOnBorrow" value="true"/> <set-property property="validationQuery" value="select 1"/> testOnBorrow的意思是从数据库连接池中取得连接时,对其的有效性进行检查 validationQuery 是用来检查的SQL语句,“select 1”执行较快,是一个不错的检测语句 c3p0需要添加一个参数: <property name="maxIdleTime"value="1800"/> maxIdleTime是连接池内连接的生存周期,使之小于mysql服务器上所设置的wait_timeout 的值 来源:

Hibernate c3p0 数据库连接池

拟墨画扇 提交于 2019-12-01 17:35:48
From : http://www.codeweblog.com/hibernate-using-c3p0-connection-pooling/ c3p0是开源JDBC连接池,Hibernate的发布版也有此功能。这篇文章描述怎样使用Hibernate来配置从c3p0。C3p0连接池配置很简单,只需要添加如下内容到 hibernate.cfg.xml文件:( 原文: c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is very simple, only needs to increase in hibernate.cfg.xml: ) <property name="hibernate.c3p0.max_size"> 20 </ property> <! - The smallest number of connections -> <property name="hibernate.c3p0.min_size"> 5 </ property> <! - Get