Class DataSourceWrapper

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

    public class DataSourceWrapper
    extends java.lang.Object
    implements javax.sql.DataSource

    A simple DataSource wrapper for the standard DriverManager class.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.sql.Connection getConnection()
      Returns a Connection using the DriverManager and all set properties.
      java.sql.Connection getConnection​(java.lang.String username, java.lang.String password)
      Always throws a SQLException.
      int getLoginTimeout()
      Always throws a SQLException.
      java.io.PrintWriter getLogWriter()
      Always throws a SQLException.
      java.util.logging.Logger getParentLogger()  
      boolean isWrapperFor​(java.lang.Class c)  
      void setDriverClassName​(java.lang.String driverClassName)  
      void setJdbcURL​(java.lang.String jdbcURL)  
      void setLoginTimeout​(int seconds)
      Always throws a SQLException.
      void setLogWriter​(java.io.PrintWriter out)
      Always throws a SQLException.
      void setPassword​(java.lang.String password)  
      void setUserName​(java.lang.String userName)  
      java.lang.Object unwrap​(java.lang.Class c)  
      • Methods inherited from class java.lang.Object

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

        createShardingKeyBuilder
      • Methods inherited from interface javax.sql.DataSource

        createConnectionBuilder
    • Constructor Detail

      • DataSourceWrapper

        public DataSourceWrapper()
    • Method Detail

      • setDriverClassName

        public void setDriverClassName​(java.lang.String driverClassName)
                                throws java.lang.ClassNotFoundException,
                                       java.lang.InstantiationException,
                                       java.lang.IllegalAccessException
        Throws:
        java.lang.ClassNotFoundException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • setJdbcURL

        public void setJdbcURL​(java.lang.String jdbcURL)
      • setUserName

        public void setUserName​(java.lang.String userName)
      • setPassword

        public void setPassword​(java.lang.String password)
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Returns a Connection using the DriverManager and all set properties.
        Specified by:
        getConnection in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String username,
                                                 java.lang.String password)
                                          throws java.sql.SQLException
        Always throws a SQLException. Username and password are set in the constructor and can not be changed.
        Specified by:
        getConnection in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getLoginTimeout

        public int getLoginTimeout()
                            throws java.sql.SQLException
        Always throws a SQLException. Not supported.
        Specified by:
        getLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        getLoginTimeout in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
        Specified by:
        getParentLogger in interface javax.sql.CommonDataSource
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
                                         throws java.sql.SQLException
        Always throws a SQLException. Not supported.
        Specified by:
        getLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        getLogWriter in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • setLoginTimeout

        public void setLoginTimeout​(int seconds)
                             throws java.sql.SQLException
        Always throws a SQLException. Not supported.
        Specified by:
        setLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        setLoginTimeout in interface javax.sql.DataSource
        Throws:
        java.sql.SQLException
      • setLogWriter

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

        public boolean isWrapperFor​(java.lang.Class c)
                             throws java.sql.SQLException
        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • unwrap

        public java.lang.Object unwrap​(java.lang.Class c)
                                throws java.sql.SQLException
        Specified by:
        unwrap in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException