public class DatabaseConnectionManager extends Object
DatabaseConnectionManager(boolean, boolean, URL, URL, boolean)| Modifier and Type | Class and Description |
|---|---|
protected class |
DatabaseConnectionManager.CheckConnectionThread |
protected class |
DatabaseConnectionManager.ReleaseThread |
protected class |
DatabaseConnectionManager.ReserveCancellationThread |
| Constructor and Description |
|---|
DatabaseConnectionManager(boolean statisticViewer,
boolean connectionsInfoToFile,
URL urlPropDB,
URL urlAutonumerical)
Class constructor.
|
DatabaseConnectionManager(boolean statisticViewer,
boolean connectionsInfoToFile,
URL urlPropDB,
URL urlAutonumerical,
boolean createInitialConnections)
Constructor that gets parameters related to database.
|
DatabaseConnectionManager(Hashtable parameters) |
DatabaseConnectionManager(URL urlDBProp,
URL urlAutonumerical,
int minConnections,
int maxConnections,
int connectionIncrement,
long timeoutBlockConnection,
long timeoutConnection,
boolean statisticViewer) |
public static String defaultUserValue
public static String defaultPasswordValue
public static final String TIMEOUT
public static final String LOCKED_TIMEOUT
public static final String INCREASE_CONNECTIONS
public static final String CONNECTION_WAIT_TIME
public static final String CONNECTION_REQUEST_TIME
public static final String MAXIMUM_CONNECTIONS
public static final String MINIMUM_CONNECTIONS
public static final String EPASSWORD
public static final String E64PASSWORD
public static final String SCHEMA
public static final String PASSWORD
public static final String USER
public static final String TEST_TABLE
public static final String CHECK_CYCLE
public static final String RELEASE_CYCLE
public static final String UPDATE_CYCLE
public static final String URL
public static final String DRIVER
public static final String DATABASE
public static final String USEJ2EECONNECTIONS
public static final String DATASOURCENAME
public static final String CONNECTION_INFO
public static final String CREATE_INITIAL_CONNECTIONS
public static final String AUTONUMERICAL_PROPERTIES
public static boolean DEBUG
public static final boolean AUTOCOMMIT_ON_UNLOCK
protected int minimum
protected int maximum
protected int connectionWaitTime
protected int connectionRequestTime
protected int increment
protected long lockTimeout
protected long timeout
public static int offset
public static String offsetString
protected DatabaseConnectionManager.ReserveCancellationThread reserveCancellationThread
protected DatabaseConnectionManager.CheckConnectionThread checkConnectionThread
protected int maxReserveTime
protected int reserveCicle
protected int checkupCicle
protected String testTable
protected boolean useJ2EEConnection
protected String dataSourceName
protected Object dataSource
protected Vector connections
protected String driver
protected String urlDB
protected String databaseId
protected String user
protected String password
protected DatabaseConnectionManager.ReleaseThread releaseThread
protected long releaseCicleThread
protected String schema
protected long updateCicleThread
protected Vector lockTime
protected double maxlocktime
protected boolean forceDisconnection
public DatabaseConnectionManager(URL urlDBProp, URL urlAutonumerical, int minConnections, int maxConnections, int connectionIncrement, long timeoutBlockConnection, long timeoutConnection, boolean statisticViewer) throws Exception
urlDBProp - URI of the database properties file pathurlAutonumerical - minConnections - maxConnections - connectionIncrement - timeoutBlockConnection - timeoutConnection - statisticViewer - Exceptionpublic DatabaseConnectionManager(boolean statisticViewer,
boolean connectionsInfoToFile,
URL urlPropDB,
URL urlAutonumerical)
statisticViewer - condition to show the statisticViewerconnectionsInfoToFile - conditions to write connections info to fileurlPropDB - URL to database properties (Relative to classpath):
urlAutonumerical - URL to autonumerical propertiespublic DatabaseConnectionManager(boolean statisticViewer,
boolean connectionsInfoToFile,
URL urlPropDB,
URL urlAutonumerical,
boolean createInitialConnections)
statisticViewer - Not usedconnectionsInfoToFile - Indicates whether information of connections is written to a
fileurlPropDB - complete path to database.properties fileurlAutonumerical - complete path to autonumerical.properties filecreateInitialConnections - Indicates whether connections are created on startup
database.properties
| attribute | values | default | required | meaning |
| URL | yes | The URL where database is stored. For example, with HSQLD engine: jdbc:hsqldb:db/myDatabase | ||
| Driver | yes | Driver for database. For example, with jdbc connection in HSQLD engine: org.hsqldb.jdbcDriver | ||
| Database | default/Postgres/SQLServer/Oracle/HSQLDB/Access | default | no | Indicates the handler used to manage operations with database. There are many available handlers. |
| User | yes | User to connect with database | ||
| Password | yes | Password to connect with database. When password in
database.properties is stored encrypted, parameter
Password must be replaced by this one. |
||
| E64Password | no | This parameter is used instead of Password
when user wants to store database password encrypted in
database.properties. |
||
| TestTable | no (but strongly recommended) | This parameter checks automatically that connection with database is OK and try to reconnect (transparently for user) when an communication error is produced among server and database. | ||
| CheckCycle | 20000 ms | no | Timer for thread where Ontimize connection pool checks database connections | |
| ReleaseCycle | 5000 ms | no | Timer for thread where Ontimize connection pool checks to release blocked connections. | |
| UpdateCycle | 500 ms | no | Time between captures of the Server Monitor where info of conections is showed | |
| MinimumConnections | 0 | yes | Minimum connection number that the connection pool will open in the start up | |
| MaximumConnections | 10 | no | Maximum connection number the the connection pool will handle | |
| IncreaseConnections | 5 | no | Connection number to be open when all the connections are being used. | |
| LockedTimeout | Long.MAX_VALUE | no | Max time the connection can be blocked. | |
| Timeout | Long.MAX_VALUE | no | Max time of inactivity to close a connection. | |
| ConnectionWaitTime | 4000 | no | Configures the max time should wait to get a connection. | |
| ConnectionRequestTime | 500 | no | Configures the time between retries to get a connection. | |
| usej2eeconnections | yes/no | no | no | Indicates when application is using J2EE DataSource for connections |
| datasourcename | no (required when usej2eeconnections is set
to 'yes' |
The name of datasource. It is the name used to do 'lookup' operation from context. |
public OntimizeConnection getOntimizeConnection() throws Exception
Exception - when Exception occurspublic OntimizeConnection getOntimizeConnection(int id) throws Exception
id - Reservation identifierExceptionprotected OntimizeConnection createConnection(String driver, String uRLBD, String user, String password) throws Exception
Exceptionpublic Connection createConnection() throws SQLException
SQLExceptionpublic void unLock(OntimizeConnection ontimizeConnection)
ontimizeConnection - Connection to unlockpublic void setAutonumerical(URL oURLAutonumerical)
public void setAutonumerical(String oPropAutonumerical)
public void setAutonumerical(Autonumerical auto)
public int getAutonumericalValue()
public Autonumerical getAutonumerical()
public int getAutonumericalValue(String table)
public void closeConnections()
protected void finalize()
throws Throwable
public int getOntimizeConnectionNumber()
public int getLockedOntimizeConnectionNumber()
public void closeLockedConnections()
public double getAverageLockTime()
public double getMaximumLockTime()
public long getUpdateCicleTime()
public String getSchema()
public void setSchema(String schema)
public void activeForceDisconnection()
throws Exception
Exceptionpublic void deactivateForceDisconnection()
throws Exception
Exceptionpublic boolean isForceDisconnectionEnabled()
public Autonumerical getAutonumerialReference()
protected Object createDataSource(String dataSourceName, Properties prop) throws Exception
Exceptionpublic String getDatabase()
public void setDriver(String driver)
public void setUrlDB(String urlDB)
public void setUser(String user)
public void setPassword(String password)
public void setMinimumConnections(int minimum)
public void setMaximumConnections(int maximum)
public int getConnectionWaitTime()
public void setConnectionWaitTime(int connectionWaitTime)
public int getConnectionRequestTime()
public void setConnectionRequestTime(int connectionRequestTime)
public void setIncrementConnections(int increment)
public void setDatabaseId(String databaseId)
public void setLockTimeout(long lockTimeout)
public void setTimeout(long timeout)
public void setCheckupCicle(int checkupCicle)
public void setReleaseCicle(long releaseCicle)
public void setUpdateCicle(long updateCicle)
public void setTestTable(String testTable)
public void setSaveConnectionsInfo(boolean connectionInfo)
Copyright © 2016 Imatia Innovation S.L.. All rights reserved.