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 simplify 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.org.slf4j.LoggergetLogger()Creates a static default Logback/sl4fj Logger for main AceQL activity.static Map<String,String>getLoggerElements()Returns the Logger elements (for debug purpose)longgetMaxBlobLength(String username, String database)Allows to define the maximum length authorized for of a Blob to be uploaded.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 the property does not exist, returns 0. - Throws:
IOException- if an IOException occursSQLException- if a SQLException occurs
-
getMaxBlobLength
Description copied from interface:DatabaseConfiguratorAllows to define the maximum length authorized for of a Blob to be uploaded. If this limit is exceeded, anIOExceptionis thrown This allows to prevent from DOS attacks that would saturate the AceQL server. 0 means there is no limit.- Specified by:
getMaxBlobLengthin interfaceDatabaseConfigurator- Parameters:
username- the client usernamedatabase- the database name as defined in the JDBC URL field- Returns:
- the value of the property
defaultDatabaseConfigurator.maxBlobLengthdefined in theaceql-server.propertiesfile at server startup. If the property does not exist, it defaults to 2GB in order to avoid DOS attacks aimed to saturate the server's disk space - 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 static default Logback/sl4fj Logger for main AceQL activity. Logger has default characteristics:- Name:
DefaultLoggerCreator - Log directory:
user.home/.kawansoft/log - File name pattern:
"aceql_%d.log.%i"(example of file created:aceql_2024-07-01.log.1.) - Pattern of each line of log:
"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"} - Maximum File Size: 300Mb
- Total Size Cap: 30Gb
DefaultLoggerCreator.propertiesfile inuser.home/.kawansoft/conf.
See the DefaultLoggerCreator.properties format.
- Specified by:
getLoggerin interfaceDatabaseConfigurator- Returns:
- the
Loggerthat will be used by AceQL logging; - Throws:
IOException- if an IOException occurs
- Name:
-
getLoggerElements
Returns the Logger elements (for debug purpose)- Returns:
- the lOGGER_ELEMENTS
-