Package org.kawanfw.sql.api.server
Class DefaultDatabaseConfigurator
java.lang.Object
org.kawanfw.sql.api.server.DefaultDatabaseConfigurator
- All Implemented Interfaces:
DatabaseConfigurator
public class DefaultDatabaseConfigurator extends Object implements DatabaseConfigurator
Default implementation of server side configuration for AceQL.
The two fully functional and secured methods are:
getConnection(String)that extractsConnectionsfrom a Tomcat JDBC Connection Pool.close(Connection)that closes theConnectionand thus releases it into the pool.
- Author:
- Nicolas de Pomereu
-
Constructor Summary
Constructors Constructor Description DefaultDatabaseConfigurator() -
Method Summary
Modifier and Type Method Description voidclose(Connection connection)Closes the connection acquired byDatabaseConfigurator.getConnection(String)with a call toConnection.close().FilegetBlobsDirectory(String username)Allows to define the directory into which Blobs/Clobs are uploaded by client side, and from which Blobs/Clobs are downloaded by client side.ConnectiongetConnection(String database)Returns aConnectionfrom Tomcat JDBC Connection Pool.
theConnectionis extracted from theDataSourcecreated by the embedded Tomcat JDBC Pool.LoggergetLogger()Creates a staticLoggerinstance.intgetMaxRows(String username, String database)Allows to define the maximum rows per request to be returned to the client.
-
Constructor Details
-
DefaultDatabaseConfigurator
public DefaultDatabaseConfigurator()
-
-
Method Details
-
getConnection
Returns aConnectionfrom Tomcat JDBC Connection Pool.
theConnectionis extracted from theDataSourcecreated by the embedded Tomcat JDBC Pool. The JDBC parameters used to create theDataSourceare defined in the properties file passed at start-up of AceQL.- Specified by:
getConnectionin interfaceDatabaseConfigurator- Parameters:
database- the database name to extract theConnectionfor.- Returns:
- the
Connectionextracted from Tomcat JDBC Connection Pool. - Throws:
SQLException- if a database access error occurs
-
close
Closes the connection acquired byDatabaseConfigurator.getConnection(String)with a call toConnection.close().
Note that Exceptions are trapped to avoid client failure. Stack trace is printed on standard error stream.- Specified by:
closein interfaceDatabaseConfigurator- Parameters:
connection- a connection to the data source- Throws:
SQLException- if a SQLException occurs
-
getMaxRows
Description copied from interface:DatabaseConfiguratorAllows to define the maximum rows per request to be returned to the client. If this limit is exceeded, the excess rows are silently dropped.- Specified by:
getMaxRowsin interfaceDatabaseConfigurator- Parameters:
username- the client username to check the max rows for.database- the database name as defined in the JDBC URL field- Returns:
- the value of the property
defaultDatabaseConfigurator.maxRowsdefined in theaceql-server.propertiesfile at server startup. If property does not exist, returns 0. - Throws:
IOException- if an IOException occursSQLException- if a SQLException occurs
-
getBlobsDirectory
Description copied from interface:DatabaseConfiguratorAllows to define the directory into which Blobs/Clobs are uploaded by client side, and from which Blobs/Clobs are downloaded by client side.
See default implementation in:getBlobsDirectory(String).- Specified by:
getBlobsDirectoryin interfaceDatabaseConfigurator- Parameters:
username- the client username- Returns:
user.home/.aceql-server-root/username. (user.homeis the one of the servlet container).- Throws:
IOException- if an IOException occursSQLException- if a SQLException occurs
-
getLogger
Creates a staticLoggerinstance.- Specified by:
getLoggerin interfaceDatabaseConfigurator- Returns:
- a static
Loggerwith properties:- Name:
"DefaultDatabaseConfigurator". - Output file pattern:
user.home/.kawansoft/log/AceQL.log. - Formatter:
SimpleFormatter. - Limit: 200Mb.
- Count (number of files to use): 2.
- Name:
- Throws:
IOException- if an IOException occurs
-