Class DBConfig

  • All Implemented Interfaces:
    java.io.Serializable

    public class DBConfig
    extends java.lang.Object
    implements java.io.Serializable
    The DBConfig class describes all the settings necessary to setup a JDBC connection to the database and to configure the connection pool.

    The configuration can be easily done via the visual AdminTool provided in SmartFoxServer 2X, however you might want to create these objects manually via code when your application requires to connect to multiple databases.

    See Also:
    SFSDBManager, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean active
      Toggles the DBManager
      int blockTime
      The amount of time to block if the BLOCK option is chosen for the exhaustedPoolAction setting
      java.lang.String connectionString
      The connection string to the database, according to the JDBC standard notation.
      java.lang.String driverName
      Fully qualified name of the database driver, for example com.mysql.jdbc.Driver
      java.lang.String exhaustedPoolAction
      The action that should be executed when the connection pool is exhausted.
      int maxActiveConnections
      The maximum number of active connections in the connection pool
      int maxIdleConnections
      The maximum number of idle connections in the connection pool
      java.lang.String password
      The password for accessing the database
      static java.lang.String POOL_ACTION_BLOCK  
      static java.lang.String POOL_ACTION_FAIL  
      static java.lang.String POOL_ACTION_GROW  
      java.lang.String testSql
      A test SQL expression that will be executed at startup to verify the integrity of the setup and connection
      java.lang.String userName
      The user name for accessing the database
    • Constructor Summary

      Constructors 
      Constructor Description
      DBConfig()  
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • POOL_ACTION_FAIL

        public static final java.lang.String POOL_ACTION_FAIL
        See Also:
        Constant Field Values
      • POOL_ACTION_BLOCK

        public static final java.lang.String POOL_ACTION_BLOCK
        See Also:
        Constant Field Values
      • POOL_ACTION_GROW

        public static final java.lang.String POOL_ACTION_GROW
        See Also:
        Constant Field Values
      • active

        public boolean active
        Toggles the DBManager
      • driverName

        public java.lang.String driverName
        Fully qualified name of the database driver, for example com.mysql.jdbc.Driver
      • connectionString

        public java.lang.String connectionString
        The connection string to the database, according to the JDBC standard notation.

        You can read more about this here: http://download.oracle.com/javase/tutorial/jdbc/basics/connecting.html

      • userName

        public java.lang.String userName
        The user name for accessing the database
      • password

        public java.lang.String password
        The password for accessing the database
      • testSql

        public java.lang.String testSql
        A test SQL expression that will be executed at startup to verify the integrity of the setup and connection

        It is recommended to use very simple SQL code such as SELECT count(*) FROM users or a similar quick SQL query.

      • maxActiveConnections

        public int maxActiveConnections
        The maximum number of active connections in the connection pool
      • maxIdleConnections

        public int maxIdleConnections
        The maximum number of idle connections in the connection pool
      • exhaustedPoolAction

        public java.lang.String exhaustedPoolAction
        The action that should be executed when the connection pool is exhausted.
        There are three main options:
        • FAIL: an exception is thrown and no more connections are allowed
        • GROW: the pool size is enlarged to accomodate the new exceeding requests. This might in turn will instantiate more resources.
        • BLOCK: block the thread for a while and retry
      • blockTime

        public int blockTime
        The amount of time to block if the BLOCK option is chosen for the exhaustedPoolAction setting
    • Constructor Detail

      • DBConfig

        public DBConfig()