connection-pooling

Connection Pooling with Spring & Hibernate

佐手、 提交于 2019-12-04 11:17:10
问题 How to configure connection pooling with Spring and Hibernate? Thanks Venu 回答1: You can use DBCP component <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialSize" value="10" /> <property name="maxActive" value=

How can I detect condition that causes exception before it happens?

梦想与她 提交于 2019-12-04 10:54:05
I had no luck with this question so I've produced this simple-as-possible-test-case to demonstrate the problem. In the code below, is it possible to detect that the connection is unusable before trying to use it? SqlConnection c = new SqlConnection(myConnString); c.Open(); // creates pool setAppRole(c); // OK c.Close(); // returns connection to pool c = new SqlConnection(myConnString); // gets connection from pool c.Open(); // ok... but wait for it... // ??? How to detect KABOOM before it happens? setAppRole(c); // KABOOM The KABOOM manifests as a error in the Windows event log; The connection

How to remove invalid database connection from pool

拟墨画扇 提交于 2019-12-04 10:32:10
问题 I am using connection pooling of tomcat with oracle database. It is working fine, but when i use my application after a long time it is giving error that " connection reset ". I am getting this error because of physical connection at oracle server closed before logical connection closed at tomcat datasource. So before getting the connection from datasource i am checking the connection validity with isValid(0) method of connection object which gives false if the physical connection was closed.

Java servlets and database connection pooling

僤鯓⒐⒋嵵緔 提交于 2019-12-04 09:51:29
Just looking at examples of connection pooling on the web, they all implement connection pooling on a per servlet basis. So each servlet has its own pool of database connections. My question is, why is that preferable to something like a global pool of db connections? Since a global pool is seems more efficient than a per servlet pool.. Also, since I'm thinking about implementing such a pool. Is there a way to have a class initialized before the servlets(I'm using jetty btw)? I'm just starting servlet development but that would seem useful for other things too like configuration. Otherwise I

Does DBCP connection pool connection.close() return connection to pool

元气小坏坏 提交于 2019-12-04 09:16:43
Using BasicDataSource from DBCP if we do a getConnection() and in the finally block we close the connection does it really return the connection to the pool or does it close the connection. The snippet code I am checking is this try { Connection conn1 = getJdbcTemplate().getDataSource() .getConnection(); //Some code to call stored proc } catch (SQLException sqlEx) { throw sqlEx; } finally { try { if (conn != null) { conn.close(); } } catch (SQLException ex1) { throw ex1; } } I was checking the source code of BasicDataSource and I reached this wrapper class for the connection. private class

How to return objects to the Pool by timeout using apache commons pool

梦想的初衷 提交于 2019-12-04 08:59:42
I'm using Apache Commons Pool library to maintaing a pool of couchbase connections (can be seen as any kind of connection, doesn't really matter). The problem I'm facing is that the only way I've found to return objects to the pool is to do it programmatically by calling the returnObject method from the GenericObjectPool class. This forces the application to guarantee the return of the object once is borrowed from the pool, regardless any exception or unexpected behavior in the application. Even though I'm controlling the return of the objects to the pool in the whole application, I find risky

How to preinitialize DBCP connection pool on startup?

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:27:54
The setup of my project is - Spring JDBC for persistence Apache DBCP 1.4 for connection pooling Mysql 5 on Linux Here is the log of my application that captures the interactions with the database. 2013-01-29 15:52:21,549 DEBUG http-bio-8080-exec-3 org.springframework.jdbc.core.JdbcTemplate - Executing SQL query [SELECT id from emp] 2013-01-29 15:52:21,558 DEBUG http-bio-8080-exec-3 org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource 2013-01-29 15:52:31,878 INFO http-bio-8080-exec-3 jdbc.connection - 1. Connection opened org.apache.commons.dbcp

ASP.NET websites under IIS 7.5 (Windows 7) running extremely slow

让人想犯罪 __ 提交于 2019-12-04 08:26:38
问题 I've just installed Windows 7 x64 Ultimate on my desktop PC. I installed IIS, Visual Studio 2008, registered ASP.NET, etc. I have this ASP.NET 3.5 website I'm working on running EXTREMELY slow on this new IIS. On STA and PROD servers (Windows 2003 Server) and on my old XP/IIS 5.1 everything runs smoothly. A page which usually takes 1-2 seconds to load is taking 8 seconds!!! I saw this post on IIS forum. It says something about Vista/7 not pooling connections (just to let you know, the website

How to setup an empty password for a MySQL connection pool in glassfish 4 from the GUI?

核能气质少年 提交于 2019-12-04 08:17:57
Im being unable to set an empty password for a MySQL connection pool from the GUI in glassfish 4. In previous versions of glassfish it used to work by simply putting "()" without the quotes. It doesnt work anymore for me in glassfish 4. By the way, I've been googling my issue with any luck. Does anyone know what is the proper way to do it in glassfish 4? Thanks in advance for you support Regards What I did to fix this was to manually in /glassfish/domains/(yourDomainName)/domain.xml add the following property to the connection pool: <property name="password" value=""></property> Remember to

Jetty mysql connection-pool configuration error: javax.naming.NameNotFoundException; remaining name 'env/jdbc/---(mysql 5.0+jetty 7.0.1)

落爺英雄遲暮 提交于 2019-12-04 07:38:20
My configuration files project/WEB-INF/web.xml : <resource-ref> <description>ConnectionPool DataSource Reference</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> project/WEB-INF/jetty-env.xml: <New id="mysql" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg></Arg> <Arg>jdbc/mysql</Arg> <Arg> <New class="org.apache.commons.dbcp.BasicDataSource"> <Set name="driverClassName">com.mysql.jdbc.Driver</Set> <Set name="url">jdbc:mysql://localhost:3306/db</Set> <Set name="username">user</Set> <Set name=