Class SimpleDataSource

  • All Implemented Interfaces:
    java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource

    public class SimpleDataSource
    extends java.lang.Object
    implements javax.sql.DataSource
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleDataSource​(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
      Constructor for SimpleDataSource.
      SimpleDataSource​(JdbcDataSource ds)
      Constructor for SimpleDataSource.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.sql.Connection getConnection()
      getConnection
      java.sql.Connection getConnection​(java.lang.String username, java.lang.String password)
      java.lang.String getDriver()
      getDriver
      int getLoginTimeout()
      getLoginTimeout
      java.io.PrintWriter getLogWriter()
      getLogWriter
      java.util.logging.Logger getParentLogger()
      java.lang.String getPassword()
      getPassword
      java.util.Properties getProperties()
      getProperties
      java.lang.Integer getTimeout()
      getTimeout
      java.lang.String getUrl()
      getUrl
      java.lang.String getUser()
      getUser
      boolean isWrapperFor​(java.lang.Class<?> iface)
      isWrapperFor
      void setLoginTimeout​(int seconds)
      void setLogWriter​(java.io.PrintWriter out)
      java.lang.String toString()
      toString
      <T> T unwrap​(java.lang.Class<T> iface)
      unwrap
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface javax.sql.CommonDataSource

        createShardingKeyBuilder
      • Methods inherited from interface javax.sql.DataSource

        createConnectionBuilder
    • Constructor Detail

      • SimpleDataSource

        public SimpleDataSource​(java.lang.String driver,
                                java.lang.String url,
                                java.lang.String user,
                                java.lang.String password)
                         throws java.lang.ClassNotFoundException

        Constructor for SimpleDataSource.

        Parameters:
        driver - a String object.
        url - a String object.
        user - a String object.
        password - a String object.
        Throws:
        java.lang.ClassNotFoundException - if any.
      • SimpleDataSource

        public SimpleDataSource​(JdbcDataSource ds)
                         throws java.lang.ClassNotFoundException

        Constructor for SimpleDataSource.

        Parameters:
        ds - a JdbcDataSource object.
        Throws:
        java.lang.ClassNotFoundException - if any.
    • Method Detail

      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException

        getConnection

        Specified by:
        getConnection in interface javax.sql.DataSource
        Returns:
        a Connection object.
        Throws:
        java.sql.SQLException - if any.
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String username,
                                                 java.lang.String password)
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
                                         throws java.sql.SQLException

        getLogWriter

        Specified by:
        getLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        getLogWriter in interface javax.sql.DataSource
        Returns:
        a PrintWriter object.
        Throws:
        java.sql.SQLException - if any.
      • getLoginTimeout

        public int getLoginTimeout()
                            throws java.sql.SQLException

        getLoginTimeout

        Specified by:
        getLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        getLoginTimeout in interface javax.sql.DataSource
        Returns:
        a int.
        Throws:
        java.sql.SQLException - if any.
      • setLogWriter

        public void setLogWriter​(java.io.PrintWriter out)
                          throws java.sql.SQLException
        Specified by:
        setLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        setLogWriter in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • setLoginTimeout

        public void setLoginTimeout​(int seconds)
                             throws java.sql.SQLException
        Specified by:
        setLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        setLoginTimeout in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
                                                 throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface javax.sql.CommonDataSource
        Throws:
        java.sql.SQLFeatureNotSupportedException
      • unwrap

        public <T> T unwrap​(java.lang.Class<T> iface)
                     throws java.sql.SQLException

        unwrap

        Specified by:
        unwrap in interface java.sql.Wrapper
        Type Parameters:
        T - a T object.
        Parameters:
        iface - a Class object.
        Returns:
        a T object.
        Throws:
        java.sql.SQLException - if any.
      • isWrapperFor

        public boolean isWrapperFor​(java.lang.Class<?> iface)
                             throws java.sql.SQLException

        isWrapperFor

        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Parameters:
        iface - a Class object.
        Returns:
        a boolean.
        Throws:
        java.sql.SQLException - if any.
      • getDriver

        public java.lang.String getDriver()

        getDriver

        Returns:
        a String object.
      • getPassword

        public java.lang.String getPassword()

        getPassword

        Returns:
        a String object.
      • getTimeout

        public java.lang.Integer getTimeout()

        getTimeout

        Returns:
        a Integer object.
      • getUrl

        public java.lang.String getUrl()

        getUrl

        Returns:
        a String object.
      • getUser

        public java.lang.String getUser()

        getUser

        Returns:
        a String object.
      • getProperties

        public java.util.Properties getProperties()

        getProperties

        Returns:
        a Properties object.
      • toString

        public java.lang.String toString()

        toString

        Overrides:
        toString in class java.lang.Object
        Returns:
        a String object.