FAQ Database Discussion Community


What is the difference b/w a Session and a Connection in Hibernate?

hibernate,session,jpa,database-connection,connection-pooling
I want to clear the basic 3 points, Does beginning a new database transaction on an old session obtains a new connection and resumes the session? Does committing a database transaction disconnects a session from the JDBC connection and returns the connection to the pool? From Hibernate Documentation, earlier versions...

Configuring c3p0 property initialPoolSize and maxStatements using Hibernate

java,hibernate,configuration,connection-pooling,c3p0
I am using Hibernate and I have configured some c3p0 properties in its config as specified in one of the hibernate documentation. Sample configuration looks like : <property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.timeout">300</property> <property name="hibernate.c3p0.max_statements">50</property> <property name="hibernate.c3p0.idle_test_period">3000</property> I came to know that c3p0 has...

Heroku PostgreSQL database connection pooling in Ruby for Rack with Puma

ruby,postgresql,heroku,connection-pooling,rack
UPDATE: I tried changing the storage of the PostgreSQL connection object from a constant POSTGRES to a class variable @@pg. That didn't fix the issue. Then, I tried changing it to a global variable $pg. That seems to have worked! I still would like to eventually implement database connection pooling,...

why does hikariCP recommend fixed size pool for better performance

java,sql-server,database,connection-pooling,hikaricp
As per hikariCP document, they have mentioned to create fixed size pool for better performance. minimumIdle*: This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool.If the idle connections dip below this value, HikariCP will make a best effort to add additional connections...

where is the urllib3 connection pool bound?

python-requests,connection-pooling,urllib3
If a new requests session is instantiated in different methods like so ... myutil.py import requests def method1(): s1 = requests.Session() def method2(): s1 = requests.Session() Where is the requests.packages.urllib3.poolmanager.PoolManager bound? Is it bound globally so that the connection pool is shared between s1 and s2, or is it bound...

Oracle data source connection pooling not working used with Spring and JDBCTemplate

java,spring,oracle11g,connection-pooling,jdbctemplate
Question: Lot of active unclosed physical connections with database even with connection pooling. Can someone tell me why is it so? I configured the connection pool settings using oracle.jdbc.pool.OracleDataSource. However it seems the physical connections are not getting closed after use. I thought, Since it is connection pooling, the connections...

JDBC connection validation performance using auto-commit, meta-data or table?

java,jdbc,webserver,connection-pooling
All, I have been researching connection validation options on several web server technologies. They are Iplanet 7 (aka Sun One Webserver) Apache Tomcat 7 Glassfish All these servers provide JDBC connection validation however in their documentation I cannot find any specifics about what type of query is used for connection...

c3p0 connection pooling, DataSources factory, how do I close the pool?

java,postgresql,sqlite,connection-pooling,c3p0
I'm trying to use C3P0 for connection pooling with both PostgreSQL and SQLite. The PostgreSQL side works no problem. I've followed the directions here, but I don't understand how to close the SQLite side down when I'm done with it. In other words, on the PostgreSQL side, where I'm using...

How can I detect whether my code is running “inside” Sidekiq server or Puma?

ruby,ruby-on-rails-4,connection-pooling,sidekiq,puma
I'm using Puma as a web server, and Sidekiq as my queue runner. For multiple things (Database connections, Redis connections, other external services) I'm using the ConnectionPool gem to manage safe access to connections. Now, depending on whether I'm running in the context of Sidekiq or of Puma, I need...

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

java,database-connection,connection-pooling,apache-commons-dbcp
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...

setMaxTotal and setDefaultMaxPerRoute in HttpClient?

java,spring,connection-pooling,apache-httpclient-4.x,resttemplate
I am using RestTemplate with HttpComponentsClientHttpRequestFactory as shown below: private RestTemplate restTemplate = new RestTemplate(); // singleton class so only one instance public DataProcess() { restTemplate.setRequestFactory(clientHttpRequestFactory()); } private ClientHttpRequestFactory clientHttpRequestFactory() { HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(1000).setConnectTimeout(1000)...

How to configure JDBC Connection Pool in Tomcat 5.5 for Oracle R12?

jdbc,connection-pooling,tomcat5.5
My Database is an Oracle R12 instance i.e 11g. The Tutorial for configuring the JDBC Connection pool shows examples up to Oracle 10g only. Link Here How do I configure a JDBC connection pool for Oracle R12 in a Tomcat 5.5 instance ? More info:: My Machine is HP-UX PA-RISC...

Testing multiple connections to SQL Server

sql-server,testing,load,database-connection,connection-pooling
We're migrating SQL2005 Enterprise to SQL2012 Enterprise (on a new server too, from WIn2003 to Win2012). Is there a way to test multiple connections to the database to prove it can take the same load as the previous server? The application is a website, .Net3.5 with Min and Max pool...

Upgrading from MySQL 5.5 to 5.6 and getting “SQLException: Connection is closed”

java,mysql,playframework-2.0,connection-pooling,bonecp
I am using the Play Framework with eBean. Upgrading to MySQL 5.6 has caused the following exception when running my database evolutions: java.sql.SQLException: Connection is closed! com.jolbox.bonecp.ConnectionHandle.checkClosed(ConnectionHandle.java:459) com.jolbox.bonecp.ConnectionHandle.prepareStatement(ConnectionHandle.java:1011) play.api.db.evolutions.Evolutions$.prepare(Evolutions.scala:128) play.api.db.evolutions.Evolutions$.updateLastProblem$1(Evolutions.scala:247)...

Hibernate Too Many Connections With Cache

java,hibernate,caching,connection-pooling,ehcache
I'm using hibernate to try and retrieve a cached query. @Transactional public interface ProductDAO extends JpaRepository<Product, Long> { @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") }) Product findByCode(String code); } I'm load testing and I'm doing this in a large loop of 1000 iterations. for (int i = 0; i...

HikariCP statement caching on MS SQL (microsoft JDBC driver 4.1)

java,connection-pooling,mssql-jdbc,hikaricp
How can I enable statement caching in MS SQL RDBMS for HikariCP connection pool ? For MySQL it is via : dataSource.cachePrepStmts=true dataSource.prepStmtCacheSize=250 dataSource.prepStmtCacheSqlLimit=2048 For PostgreSQL via: hikari.dataSource.prepareThreshold=1 For Oracle, the following works: dataSource.implicitCachingEnabled=true and adjusting via setMaxStatements() method of OracleDataSource But I have not found anything for MS SQL...

Tomcat validates connection on every borrow

java,tomcat,jdbc,connection-pooling
I am using Tomcat 7 (jdk 1.6) in Eclipse 4.3.2. I configured my Connection Pool as below : <Resource name="jdbc/myDS" auth="Container" type="javax.sql.DataSource" driverClassName="com.p6spy.engine.spy.P6SpyDriver" url="jdbc:p6spy:oracle:thin:@server:1521:XXX" username="XXX" password="XXX" maxActive="2" maxIdle="2" maxWait="-1" validationInterval="30000" validationQuery="SELECT 1 FROM DUAL" /> I am using Spring 3.2.14, Hibernate 3.2.6-GA, CXF 2.7. Every time I receive a SOAP...

Reasons why resources in c3p0 cannot get checked out?

java,connection,stack-overflow,connection-pooling,c3p0
So I was looking into the c3p0 API to debug one of our production issues which was resulting in a stack overflow error while checking out a connection. I found below comments in BasicResourcePool class's checkoutResource method: /* * This function recursively calls itself... under nonpathological * situations, it shouldn't...

JAVA + flex application Crashes after trying exporting large amount data into .CSV

java,hibernate,postgresql,csv,connection-pooling
My application is a Java EE+Flex app and i use to show some data from postgres If i show 100 data lines and export them into a csv it works If i try to export a large amount of data like 300+ 400++ the whole application crash and i get...

Convert org.apache.tomcat.jdbc.pool.DataSource to org.apache.commons.dbcp.BasicDataSource

grails,connection-pooling
Upgrading from Grails 2.2.1 to 2.4.3 everything else has upgraded fine, but having an issue with the Tomcat upgrade to 7.0.54 I am getting an error of Error initializing the application: Error creating bean with name 'dataSourceMBean': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.apache.commons.dbcp.BasicDataSource]: Could...

what exactly does a database connection mean in connection pool

java,database,connection-pooling
Let say I have a db connection pool of 3 connection. Does it means that There are three active TCP connection with db ? only 3 query can be run in parallel, one query per connection ? ...

MySQL Fabric failover and Connection Pooling with Hibernate

mysql,hibernate,jdbc,connection-pooling,mysql-fabric
I'm attempting to implement automatic failover via a MySQL Fabric Server Group using a JNDI Resource, Hibernate, and Connection Pooling. Our DB farm is properly setup with MySQL Fabric and I'm attempting to implement the client/connector. I have a JNDI resource declared in my server.xml file which has a MySQL...

HibernateUtil does not return connection to c3p0 pool

java,multithreading,hibernate,connection-pooling,c3p0
After some problems with database connections timing out using Hibernate in our GWT webapp we chose to use c3p0 as a connection pool provider. Now I have a different problem: The app does not seem to return connections to the pool. Instead it stalls on the first database access. To...

How to configure the connection pool in Play Framework 1.3 through application.conf and c3p0.properties?

playframework,connection-pooling,c3p0,playframework-1.x
I'm configured the Play 1.3 application to use four databases (on three different servers). There was a problem of leakage connections, this problem has been partially solved, I wrote about this - Do I need to annotate JPA actions with @Transactional in Play Framework-1.x to prevent the connection leak? Now...

Reusing connections in Django with Python Requests

python,django,python-requests,connection-pooling,keep-alive
What's the correct way of reusing Python Requests connections in Django across multiple HTTP requests. That's what I'm doing currently: import requests def do_request(data): return requests.get('http://foo.bar/', data=data, timeout=4) def my_view1(request) req = do_request({x: 1}) ... def my_view2(request) req = do_request({y: 2}) ... So, I have one function that makes the...

When Entity Framework Connection Gets Open & Closed

c#,asp.net,entity-framework,connection-pooling
I have an asp.net web forms application it uses EF for all database activities. When page loads I have to fetch lot of data from different tables. I have a DataAccessor class where I am having a member variable of Entity Framework DbContext (MyDBEntities). See class definition below. public class...

Database connection pool[Hikari] initialize error

java,web-applications,database-connection,connection-pooling,hikaricp
Am trying to configure HikariCP for my web application, am not using any frameworks, its plain simple java web app. When i tried establishing connection through normal JDBC it was successful, i was able to perform all database operations. However, with a CP when am trying to get an connection...

Gracefully shutdown GWT super dev mode

gwt,database-connection,connection-pooling,shutdown,gwt-super-dev-mode
Quick explanation For a project I am involved with, created in GWT 2.7 using Eclipse Luna as IDE, in our server code we have a connection pool (backend is a mariadb database) configured with Hikari (http://brettwooldridge.github.io/HikariCP/). This all works fine, except for one thing.. The problem To avoid our database...

Set connection pool size for DBCP datasource in iBatis

connection-pooling,mybatis,ibatis,apache-commons-dbcp
How can one set the connection pool size for a DBCP datasource? Also, is the default datasource pooled? I tried to set maxTotal (http://commons.apache.org/proper/commons-dbcp/configuration.html), but it returns an invalid property error. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${db.driver}"/> <property name="url" value="${db.url}"/> <property name="username" value="${db.username}"/> <property name="password"...

c3p0 connection checkout taking 15 minutes to fail at times

oracle,connection-pooling,c3p0
hit a problem using c3p0. In most cases works fine, but in prod env behind firewalls ocasionally fails to checkout connection. The problem is that it takes it 15 minutes to recognize connection is not usable. The pool is not exausted as other connection are being checked out and used...

Connection Pool Empty Hibernate 4, but Unable to Find the Culprit

hibernate,tomcat,transactions,sql-server-2012,connection-pooling
I'm monitoring the SQL database for connections every 5 minutes. For days it'll hover around 5 connections (my idle) then suddenly I'm at 50. Obviously this is a recursive issue because I can't see why I would jump from 5 to 50 within 5 minutes with zero traffic. I'm using...

Tomcat connection pooling reset by sql server 2008 and 2012

sql-server,connection-pooling
I have 5 different modules connecting sql server 2008 and 2012 using Tomcat connection pooling. In the Tomcat7\conf\context.xml <Resource auth="Container" driverClassName="net.sourceforge.jtds.jdbc.Driver" logAbandoned="true" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/testservice2" password="abc" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor" username="abc"/> Module 1 - In the...

How to set application_name for postgres connections?

java,postgresql,connection-pooling,tomcat-jdbc
I'm using tomcat connection pool org.apache.tomcat.jdbc.pool.DataSource. The connections appear in my database pg_stat_activity with empty application_name. How could I set that application name in my java app, so I know where each connection comes from (as there will be multiple applications accessing the same db)?...

Redis Cluster in multiple threads

multithreading,redis,thread-safety,connection-pooling,jedis
Im currently using Redis Cluster Mode with 3 master instances, i'm using Jedis(Java client) in listening server which every data received i create a new thread then the thread make an update in redis. My question is how can i use Redis Cluster instance in multiple thread with pool configuration....