Class MariaDbPoolDataSource

    • Constructor Detail

      • MariaDbPoolDataSource

        public MariaDbPoolDataSource​(String hostname,
                                     int port,
                                     String database)
        Constructor.
        Parameters:
        hostname - hostname (ipv4, ipv6, dns name)
        port - server port
        database - database name
      • MariaDbPoolDataSource

        public MariaDbPoolDataSource​(String url)
      • MariaDbPoolDataSource

        public MariaDbPoolDataSource()
        Default constructor. hostname will be localhost, port 3306.
    • Method Detail

      • getDatabaseName

        public String getDatabaseName()
        Gets the name of the database.
        Returns:
        the name of the database for this data source
      • setDatabaseName

        public void setDatabaseName​(String database)
                             throws SQLException
        Sets the database name.
        Parameters:
        database - the name of the database
        Throws:
        SQLException - if error in URL
      • getUser

        public String getUser()
        Gets the username.
        Returns:
        the username to use when connecting to the database
      • setUser

        public void setUser​(String user)
                     throws SQLException
        Sets the username.
        Parameters:
        user - the username
        Throws:
        SQLException - if error in URL
      • setPassword

        public void setPassword​(String password)
                         throws SQLException
        Sets the password.
        Parameters:
        password - the password
        Throws:
        SQLException - if error in URL
      • getPort

        public int getPort()
        Returns the port number.
        Returns:
        the port number
      • setPort

        public void setPort​(int port)
                     throws SQLException
        Sets the database port.
        Parameters:
        port - the port
        Throws:
        SQLException - if error in URL
      • getPortNumber

        public int getPortNumber()
        Returns the port number.
        Returns:
        the port number
      • setPortNumber

        public void setPortNumber​(int port)
                           throws SQLException
        Sets the port number.
        Parameters:
        port - the port
        Throws:
        SQLException - if error in URL
        See Also:
        setPort(int)
      • setUrl

        public void setUrl​(String url)
                    throws SQLException
        Sets the connection string URL.
        Parameters:
        url - the connection string
        Throws:
        SQLException - if error in URL
      • getServerName

        public String getServerName()
        Returns the name of the database server.
        Returns:
        the name of the database server
      • setServerName

        public void setServerName​(String serverName)
                           throws SQLException
        Sets the server name.
        Parameters:
        serverName - the server name
        Throws:
        SQLException - if error in URL
      • getConnection

        public Connection getConnection()
                                 throws SQLException
        Attempts to establish a connection with the data source that this DataSource object represents.
        Specified by:
        getConnection in interface DataSource
        Returns:
        a connection to the data source
        Throws:
        SQLException - if a database access error occurs
      • getConnection

        public Connection getConnection​(String username,
                                        String password)
                                 throws SQLException
        Attempts to establish a connection with the data source that this DataSource object represents.
        Specified by:
        getConnection in interface DataSource
        Parameters:
        username - the database user on whose behalf the connection is being made
        password - the user's password
        Returns:
        a connection to the data source
        Throws:
        SQLException - if a database access error occurs
      • getPooledConnection

        public PooledConnection getPooledConnection()
                                             throws SQLException
        Attempts to establish a physical database connection that can be used as a pooled connection.
        Specified by:
        getPooledConnection in interface ConnectionPoolDataSource
        Returns:
        a PooledConnection object that is a physical connection to the database that this ConnectionPoolDataSource object represents
        Throws:
        SQLException - if a database access error occurs if the JDBC driver does not support this method
      • getPooledConnection

        public PooledConnection getPooledConnection​(String user,
                                                    String password)
                                             throws SQLException
        Attempts to establish a physical database connection that can be used as a pooled connection.
        Specified by:
        getPooledConnection in interface ConnectionPoolDataSource
        Parameters:
        user - the database user on whose behalf the connection is being made
        password - the user's password
        Returns:
        a PooledConnection object that is a physical connection to the database that this ConnectionPoolDataSource object represents
        Throws:
        SQLException - if a database access error occurs
      • getLogWriter

        public PrintWriter getLogWriter()
        Retrieves the log writer for this DataSource object.

        The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.DriverManager class.

        When a DataSource object is created, the log writer is initially null; in other words, the default is for logging to be disabled.

        Specified by:
        getLogWriter in interface CommonDataSource
        Specified by:
        getLogWriter in interface ConnectionPoolDataSource
        Specified by:
        getLogWriter in interface DataSource
        Specified by:
        getLogWriter in interface XADataSource
        Returns:
        the log writer for this data source or null if logging is disabled
        See Also:
        setLogWriter(java.io.PrintWriter)
      • setLogWriter

        public void setLogWriter​(PrintWriter out)
        Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

        The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source- specific log writer are not printed to the log writer associated with the java.sql.DriverManager class. When a DataSource object is created the log writer is initially null; in other words, the default is for logging to be disabled.

        Specified by:
        setLogWriter in interface CommonDataSource
        Specified by:
        setLogWriter in interface ConnectionPoolDataSource
        Specified by:
        setLogWriter in interface DataSource
        Specified by:
        setLogWriter in interface XADataSource
        Parameters:
        out - the new log writer; to disable logging, set to null
        Since:
        1.4
        See Also:
        getLogWriter()
      • unwrap

        public <T> T unwrap​(Class<T> iface)
                     throws SQLException
        Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

        If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

        Specified by:
        unwrap in interface Wrapper
        Parameters:
        iface - A Class defining an interface that the result must implement.
        Returns:
        an object that implements the interface. May be a proxy for the actual implementing object.
        Throws:
        SQLException - If no object found that implements the interface
        Since:
        1.6
      • isWrapperFor

        public boolean isWrapperFor​(Class<?> interfaceOrWrapper)
                             throws SQLException
        Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.
        Specified by:
        isWrapperFor in interface Wrapper
        Parameters:
        interfaceOrWrapper - a Class defining an interface.
        Returns:
        true if this implements the interface or directly or indirectly wraps an object that does.
        Throws:
        SQLException - if an error occurs while determining whether this is a wrapper for an object with the given interface.
        Since:
        1.6
      • getUrlParser

        protected UrlParser getUrlParser()
        For testing purpose only.
        Returns:
        current url parser.
      • getPoolName

        public String getPoolName()
      • getMaxPoolSize

        public int getMaxPoolSize()
        Pool maximum connection size.
        Returns:
        current value.
      • getMinPoolSize

        public int getMinPoolSize()
        Get minimum pool size (pool will grow at creation untile reaching this size). Null mean use the pool maximum pool size.
        Returns:
        current value.
      • getMaxIdleTime

        public int getMaxIdleTime()
        Max time a connection can be idle.
        Returns:
        current value.
      • getStaticGlobal

        public Boolean getStaticGlobal()
      • setStaticGlobal

        public void setStaticGlobal​(Boolean staticGlobal)
      • getPoolValidMinDelay

        public Integer getPoolValidMinDelay()
        If connection has been used in less time than poolValidMinDelay, then no connection validation will be done (0=mean validation every time).
        Returns:
        current value of poolValidMinDelay
      • setPoolValidMinDelay

        public void setPoolValidMinDelay​(Integer poolValidMinDelay)
      • initialize

        public void initialize()
                        throws SQLException
        Initialize pool.
        Throws:
        SQLException - if connection string has error
      • testGetConnectionIdleThreadIds

        public List<Long> testGetConnectionIdleThreadIds()
        Get current idle threads. !! For testing purpose only !!
        Returns:
        current thread id's
      • testForceMaxIdleTime

        public void testForceMaxIdleTime​(int maxIdleTime)
                                  throws SQLException
        Permit to create test that doesn't wait for maxIdleTime minimum value of 60 seconds. !! For testing purpose only !!
        Parameters:
        maxIdleTime - forced value of maxIdleTime option.
        Throws:
        SQLException - if connection string has error
      • testGetPool

        public Pool testGetPool()
        Get pool. !! For testing purpose only !!
        Returns:
        pool