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:

Author:
Nicolas de Pomereu
  • Constructor Details

    • DefaultDatabaseConfigurator

      public DefaultDatabaseConfigurator()
  • Method Details

    • getConnection

      public Connection getConnection​(String database) throws SQLException
      Returns a Connection from Tomcat JDBC Connection Pool.

      the Connection is extracted from the DataSource created by the embedded Tomcat JDBC Pool. The JDBC parameters used to create the DataSource are defined in the properties file passed at start-up of AceQL.
      Specified by:
      getConnection in interface DatabaseConfigurator
      Parameters:
      database - the database name to extract the Connection for.
      Returns:
      the Connection extracted from Tomcat JDBC Connection Pool.
      Throws:
      SQLException - if a database access error occurs
    • close

      public void close​(Connection connection) throws SQLException
      Closes the connection acquired by DatabaseConfigurator.getConnection(String) with a call to Connection.close().
      Note that Exceptions are trapped to avoid client failure. Stack trace is printed on standard error stream.
      Specified by:
      close in interface DatabaseConfigurator
      Parameters:
      connection - a connection to the data source
      Throws:
      SQLException - if a SQLException occurs
    • getMaxRows

      public int getMaxRows​(String username, String database) throws IOException, SQLException
      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 interface DatabaseConfigurator
      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 default.maxRows defined in the aceql-server.properties file at server startup. If property does not exist, returns 0.
      Throws:
      IOException - if an IOException occurs
      SQLException - if a SQLException occurs
    • getBlobsDirectory

      public File getBlobsDirectory​(String username) throws IOException, SQLException
      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 interface DatabaseConfigurator
      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 occurs
      SQLException - if a SQLException occurs
    • getLogger

      public Logger getLogger() throws IOException
      Creates a static Logger instance.
      Specified by:
      getLogger in interface DatabaseConfigurator
      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.
      Throws:
      IOException - if an IOException occurs