Class NonRegisteringDriver

  • All Implemented Interfaces:
    java.sql.Driver
    Direct Known Subclasses:
    Driver

    public class NonRegisteringDriver
    extends java.lang.Object
    implements java.sql.Driver
    MariaDB Driver that doesn't register itself to DriverManager
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern identifierPattern  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptsURL​(java.lang.String url)
      returns true if the driver can accept the url.
      Connection connect​(java.lang.String url, java.util.Properties props)
      Connect to the given connection string.
      static Connection connect​(Configuration configuration)
      Connect according to configuration
      static java.lang.String enquoteIdentifier​(java.lang.String identifier, boolean alwaysQuote)  
      static java.lang.String enquoteLiteral​(java.lang.String val)
      Enquote String value.
      static java.lang.String enquoteLiteral​(java.lang.String val, boolean noBackslashEscapes)
      Enquote String value, escaping according to the server sql_mode.
      int getMajorVersion()
      gets the major version of the driver.
      int getMinorVersion()
      gets the minor version of the driver.
      java.util.logging.Logger getParentLogger()  
      java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties info)
      Get the property info.
      static boolean isSimpleIdentifier​(java.lang.String identifier)
      Retrieves whether identifier is a simple SQL identifier.
      boolean jdbcCompliant()
      checks if the driver is jdbc compliant.
      private static boolean mustEscapeLiteral​(char c, boolean noBackslashEscapes)  
      • Methods inherited from class java.lang.Object

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

      • identifierPattern

        private static final java.util.regex.Pattern identifierPattern
    • Constructor Detail

      • NonRegisteringDriver

        public NonRegisteringDriver()
    • Method Detail

      • connect

        public static Connection connect​(Configuration configuration)
                                  throws java.sql.SQLException
        Connect according to configuration
        Parameters:
        configuration - configuration
        Returns:
        a Connection
        Throws:
        java.sql.SQLException - if connect fails
      • connect

        public final Connection connect​(java.lang.String url,
                                        java.util.Properties props)
                                 throws java.sql.SQLException
        Connect to the given connection string.
        Specified by:
        connect in interface java.sql.Driver
        Parameters:
        url - the url to connect to
        Returns:
        a connection
        Throws:
        java.sql.SQLException - if it is not possible to connect
      • acceptsURL

        public final boolean acceptsURL​(java.lang.String url)
        returns true if the driver can accept the url.
        Specified by:
        acceptsURL in interface java.sql.Driver
        Parameters:
        url - the url to test
        Returns:
        true if the url is valid for this driver
      • getPropertyInfo

        public final java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url,
                                                                   java.util.Properties info)
                                                            throws java.sql.SQLException
        Get the property info.
        Specified by:
        getPropertyInfo in interface java.sql.Driver
        Parameters:
        url - the url to get properties for
        info - the info props
        Returns:
        all possible connector options
        Throws:
        java.sql.SQLException - if there is a problem getting the property info
      • getMajorVersion

        public final int getMajorVersion()
        gets the major version of the driver.
        Specified by:
        getMajorVersion in interface java.sql.Driver
        Returns:
        the major versions
      • getMinorVersion

        public final int getMinorVersion()
        gets the minor version of the driver.
        Specified by:
        getMinorVersion in interface java.sql.Driver
        Returns:
        the minor version
      • jdbcCompliant

        public final boolean jdbcCompliant()
        checks if the driver is jdbc compliant.
        Specified by:
        jdbcCompliant in interface java.sql.Driver
        Returns:
        true since the driver is not compliant
      • getParentLogger

        public final java.util.logging.Logger getParentLogger()
                                                       throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface java.sql.Driver
        Throws:
        java.sql.SQLFeatureNotSupportedException
      • enquoteIdentifier

        public static java.lang.String enquoteIdentifier​(java.lang.String identifier,
                                                         boolean alwaysQuote)
                                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • enquoteLiteral

        public static java.lang.String enquoteLiteral​(java.lang.String val)
        Enquote String value.
        Parameters:
        val - string value to enquote
        Returns:
        enquoted string value
      • enquoteLiteral

        public static java.lang.String enquoteLiteral​(java.lang.String val,
                                                      boolean noBackslashEscapes)
        Enquote String value, escaping according to the server sql_mode.

        The single quote is always doubled (''), which is safe under every sql_mode. When backslash escaping is enabled (default sql_mode) the backslash and the usual control characters are backslash-escaped too; under NO_BACKSLASH_ESCAPES the backslash is a literal character, so only the quote is doubled and every other character is left untouched.

        Parameters:
        val - string value to enquote
        noBackslashEscapes - whether the server runs with NO_BACKSLASH_ESCAPES sql_mode
        Returns:
        enquoted string value
      • mustEscapeLiteral

        private static boolean mustEscapeLiteral​(char c,
                                                 boolean noBackslashEscapes)
      • isSimpleIdentifier

        public static boolean isSimpleIdentifier​(java.lang.String identifier)
        Retrieves whether identifier is a simple SQL identifier. The first character is an alphabetic character from a through z, or from A through Z The string only contains alphanumeric characters or the characters "_" and "$"
        Parameters:
        identifier - identifier
        Returns:
        true if identifier doesn't have to be quoted
        See Also:
        mariadb identifier name