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 extractsConnections
from a Tomcat JDBC Connection Pool.close(Connection)
that closes theConnection
and thus releases it into the pool.
- Author:
- Nicolas de Pomereu
-
Constructor Summary
Constructors Constructor Description DefaultDatabaseConfigurator()
-
Method Summary
Modifier and Type Method Description void
close(Connection connection)
Closes the connection acquired byDatabaseConfigurator.getConnection(String)
with a call toConnection.close()
.File
getBlobsDirectory(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.Connection
getConnection(String database)
Returns aConnection
from Tomcat JDBC Connection Pool.
theConnection
is extracted from theDataSource
created by the embedded Tomcat JDBC Pool.Logger
getLogger()
Creates a staticLogger
instance.int
getMaxRows(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 aConnection
from Tomcat JDBC Connection Pool.
theConnection
is extracted from theDataSource
created by the embedded Tomcat JDBC Pool. The JDBC parameters used to create theDataSource
are defined in the properties file passed at start-up of AceQL.- Specified by:
getConnection
in interfaceDatabaseConfigurator
- Parameters:
database
- the database name to extract theConnection
for.- Returns:
- the
Connection
extracted 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:
close
in interfaceDatabaseConfigurator
- Parameters:
connection
- a connection to the data source- Throws:
SQLException
- if a SQLException occurs
-
getMaxRows
Description copied from interface:DatabaseConfigurator
Allows 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:
getMaxRows
in 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.maxRows
defined in theaceql-server.properties
file 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:DatabaseConfigurator
Allows 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:
getBlobsDirectory
in interfaceDatabaseConfigurator
- Parameters:
username
- the client username- Returns:
user.home/.aceql-server-root/username
. (user.home
is the one of the servlet container).- Throws:
IOException
- if an IOException occursSQLException
- if a SQLException occurs
-
getLogger
Creates a staticLogger
instance.- Specified by:
getLogger
in interfaceDatabaseConfigurator
- Returns:
- a static
Logger
with 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
-