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 defaultDatabaseConfigurator.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 org.slf4j.Logger getLogger() throws IOException
      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_2022-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
      These default values may be superseded by creating a DefaultLoggerCreator.properties file in user.home/.kawansoft/conf.

      See the DefaultLoggerCreator.properties format.


      Specified by:
      getLogger in interface DatabaseConfigurator
      Returns:
      the Logger that will be used by AceQL logging;
      Throws:
      IOException - if an IOException occurs
    • getLoggerElements

      public static Map<String,​String> getLoggerElements()
      Returns the Logger elements (for debug purpose)
      Returns:
      the lOGGER_ELEMENTS