Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JDBC Internal pool connections(Control/Monitor Connection Pools created by EclipseLink)
JDBC Internal pool connections [message #1734711] Fri, 10 June 2016 13:34 Go to next message
Shannon Scott is currently offline Shannon ScottFriend
Messages: 3
Registered: June 2016
Junior Member
The system I am working on requires that each user connect to the database with their own schema so reads and writes are audited.
No matter how I configure the connection-pool, eclipselink log shows three (3) connections when the Entity Manager is created.
This is my current persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
  <persistence-unit name="xxx" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <!--  BMV Entity Classes -->
    <class>zzz</class> 	  

    <properties>
      <!-- default, can be overridden -->
      <property name="javax.persistence.jdbc.user" value="USERNAME"/> 
      <!-- default, can be overridden -->
      <property name="javax.persistence.jdbc.password" value="PASSWORD"/> 
      <!-- default, can be overridden -->
      <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:sid"/>
      
      <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
      <property name="eclipselink.jdbc.exclusive-connection.mode" value="Always"/>
      <property name="eclipselink.jdbc.exclusive-connection.is-lazy" value="true"/>
      <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.OraclePlatform"/>
      <property name="eclipselink.jdbc.native-sql" value="true"/>
      <property name="eclipselink.connection-pool.default.initial" value="0"/>
      <property name="eclipselink.connection-pool.default.min" value="0"/>
      <property name="eclipselink.connection-pool.default.max" value="1"/>
      <property name="eclipselink.logging.level" value="INFO"/>
    </properties>
  </persistence-unit>
</persistence>


I am creating the entity manager like this:
if (user != null) {
  properties.put(PersistenceUnitProperties.JDBC_USER, user.getName());
  properties.put(PersistenceUnitProperties.JDBC_PASSWORD, user.getPassword());
  properties.put(PersistenceUnitProperties.JDBC_URL, user.getJdbcURL());
}
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName, properties);           
EntityManager em = emf.createEntityManager();


This is the log (3 connections for a single read):
connection|connecting(DatabaseLogin(
	platform=>OraclePlatform
	user name=> "USERNAME"
	datasource URL=> "jdbc:oracle:thin:@localhost:1521:SID"
))
connection|connecting(DatabaseLogin(
	platform=>OraclePlatform
	user name=> "USERNAME"
	datasource URL=> "jdbc:oracle:thin:@localhost:1521:SID"
))
connection|connecting(DatabaseLogin(
	platform=>OraclePlatform
	user name=> "USERNAME"
	datasource URL=> "jdbc:oracle:thin:@localhost:1521:SID"
))
connection|Connected: jdbc:oracle:thin:@localhost:1521:SID
	User: USERNAME
	Database: Oracle  Version: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
	Driver: Oracle JDBC driver  Version: 11.2.0.3.0
connection|Connected: jdbc:oracle:thin:@localhost:1521:SID
	User: USERNAME
	Database: Oracle  Version: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
	Driver: Oracle JDBC driver  Version: 11.2.0.3.0
connection|Connected: jdbc:oracle:thin:@localhost:1521:SID
	User: USERNAME
	Database: Oracle  Version: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
	Driver: Oracle JDBC driver  Version: 11.2.0.3.0
connection|Connection acquired from connection pool [default].
connection|Connection released to connection pool [default].
connection|file:/xxx_url=jdbc:oracle:thin:@localhost:1521:SID_user=USERNAME login successful
connection|file:/xxx_url=jdbc:oracle:thin:@localhost:1521:SID_user=USERNAME login successful
connection|client acquired: 19000190
query|Execute query ReadAllQuery(referenceClass=SqlClass sql="SQL")
connection|Connection acquired from connection pool [default].
connection|Connection released to connection pool [default].
connection|client released
connection|disconnect
connection|disconnect
connection|disconnect
connection|file:/xxx_url=jdbc:oracle:thin:@localhost:1521:SID_user=USERNAME logout successful
connection|file:/xxx_url=jdbc:oracle:thin:@localhost:1521:SID_user=USERNAME logout successful
connection|disconnect
connection|disconnect
connection|disconnect

I tried using a SessionCustomizer with these lines, but it has no affect:
  ConnectionPool defaultPool = ((ServerSession)session).getConnectionPool("default");
  ((ServerSession)session).getSequencingControl().setConnectionPool(defaultPool);
  ((ServerSession)session).setReadConnectionPool(defaultPool);


Can I control the EclipseLink Internal Connection Pools?
Also, I would like to monitor these eclipselink connection pools (something like PSI Probe DataSource monitor).
Is there any tool that provides this monitoring, or could anyone provide pointers if I wanted to access the required info to write my own monitor?
Thank you for any advice or help.
Re: JDBC Internal pool connections [message #1734896 is a reply to message #1734711] Mon, 13 June 2016 15:11 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
The connections you may see being logged could be initial connection validation done during the deployment phase - it is hard to tell without more information being logged, and since deployment isn't completed by default until the persistence context is first accessed, it may appear to be related to the query when this is really just the first time it is accessed.

If you wanted to use a DataSource probe, I would encourage you to create your own datasource class and pass it through properties as shown here http://onpersistence.blogspot.com/2008/04/eclipselink-and-datasources.html
Previous Topic:Difference between static and dynamic weaving
Next Topic:EclipseLink Static Weaving Maven Plugin Lifecycle Mapping Problem
Goto Forum:
  


Current Time: Fri Dec 15 10:31:32 GMT 2017

Powered by FUDForum. Page generated in 0.02312 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software