Class JenaDriver

  • All Implemented Interfaces:
    java.sql.Driver
    Direct Known Subclasses:
    MemDriver, RemoteEndpointDriver, TDBDriver

    public abstract class JenaDriver
    extends java.lang.Object
    implements java.sql.Driver

    Abstract implementation of a Jena JDBC driver

    Connection URLs

    All Jena JDBC drivers are expected to have connection URLs which start with the following:

     jdbc:jena:foo:
     

    The jdbc:jena: portion is the common prefix for all Jena JDBC drivers, the foo: portion is an implementation specific prefix. Each Jena JDBC driver will have a different foo: prefix chosen such that it appropriately identifies at a glance the type of the underlying RDF database.

    Connection URL Parameters

    After the prefix a Jena JDBC connection URL consists of a sequence of key value pairs, the characters ampersand (&), semicolon (;) and pipe (|) are considered to be separators between pairs, the separators are reserved characters and may not be used in values. The key is separated from the value by a equals sign (=) though unlike the separators this is not a reserved character in values.

    There is no notion of character escaping in connection parameters so if you need to use any of the reserved characters in your values then you should pass these to the connect(String, Properties) method directly in the Properties object.

    Common Parameters

    There are some common parameter understood by all Jena JDBC drivers and which apply regardless of driver implementation.

    JDBC Compatibility Level

    The first of these is the jdbc-compatibility parameter. To avoid typos when creating URLs programmatically a constant ( PARAM_JDBC_COMPATIBILITY) is provided which contains the parameter name exactly as the code expects it. This parameter provides an integer value in the range 1-9 which denotes how compatible the driver should attempt to be, see JdbcCompatibility for discussion on the meaning of compatibility levels.

    When not set the JdbcCompatibility.DEFAULT compatibility level is used, note that JenaConnection objects support changing this after the connection has been established.

    Pre-Processors

    The second of these is the pre-processor parameter which is used to specify one/more CommandPreProcessor implementations to use. The parameter should be specified once for each pre-processor you wish to you and you should supply a fully qualified class name to ensure the pre-processor can be loaded and registered on your connections. The driver will report an error if you specify a class that cannot be appropriately loaded and registered.

    Pre-processors are registered in the order that they are specified so if you use multiple pre-processors and they have ordering dependencies please ensure that you specify them in the desired order. Note that JenaConnection objects support changing registered pre-processors after the connection has been established.

    Post-Processors

    There is also a post-processor parameter which is used to specify one/more ResultsPostProcessor implementations to use. The parameter should be specified once for each post-processor you wish to use and you should supply a fully qualified class name to ensure the post-processor can be loaded and registered on your connections. The driver will report an error is you specify a class that cannot be appropriately loaded and registered.

    Post-processors are registered in the order that they are specified so if you use multiple post-processors and they have ordering dependencies please ensure that you specify them in the desired order. Note that JenaConnection objects support changing registered post-processors after the connection has been established.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DRIVER_PREFIX
      Constant for the primary Jena JDBC Driver prefix, implementations supply an additional prefix which will form the next portion of the JDBC URL
      static java.lang.String NO_AUTO_LOGGING_CONFIGURATION
      Deprecated.
      static java.lang.String PARAM_CONFIG
      Constant for the connection URL parameter used to set the path to a Java properties file used to provide additional connection parameters external to the URL.
      static java.lang.String PARAM_JDBC_COMPATIBILITY
      Constant for the connection URL parameter which sets the desired JDBC compatibility level
      static java.lang.String PARAM_LOGGING
      Deprecated.
      No longer supported as of Jena 4.x
      static java.lang.String PARAM_PASSWORD
      Constant for the standard JDBC connection URL parameter used to set password for drivers that support authentication
      static java.lang.String PARAM_POST_PROCESSOR
      Constant for the connection URL parameter used to set class names of ResultsPostProcessor implementations to use with returned connections.
      static java.lang.String PARAM_PRE_PROCESSOR
      Constant for the connection URL parameter used to set class names of CommandPreProcessor implementations to use with returned connections.
      static java.lang.String PARAM_USERNAME
      Constant for the standard JDBC connection URL parameter used to set user name for drivers that support authentication
    • Constructor Summary

      Constructors 
      Constructor Description
      JenaDriver​(int majorVer, int minorVer, java.lang.String prefix)
      Creates a new driver
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptsURL​(java.lang.String url)  
      java.sql.Connection connect​(java.lang.String url, java.util.Properties props)  
      int getMajorVersion()  
      int getMinorVersion()  
      java.util.logging.Logger getParentLogger()  
      java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url, java.util.Properties props)  
      boolean jdbcCompliant()
      Returns that a Jena JDBC driver is not JDBC compliant since strict JDBC compliance requires support for SQL-92 and since we are using SPARQL we don't meet that criteria
      • Methods inherited from class java.lang.Object

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

      • DRIVER_PREFIX

        public static final java.lang.String DRIVER_PREFIX
        Constant for the primary Jena JDBC Driver prefix, implementations supply an additional prefix which will form the next portion of the JDBC URL
        See Also:
        Constant Field Values
      • PARAM_JDBC_COMPATIBILITY

        public static final java.lang.String PARAM_JDBC_COMPATIBILITY
        Constant for the connection URL parameter which sets the desired JDBC compatibility level
        See Also:
        Constant Field Values
      • PARAM_PRE_PROCESSOR

        public static final java.lang.String PARAM_PRE_PROCESSOR
        Constant for the connection URL parameter used to set class names of CommandPreProcessor implementations to use with returned connections.

        This parameter may be specified multiple times and pre-processors will be registered (and thus applied) in the order specified. If any pre-processors are passed as part of the Properties object rather than in the connection URL then these will be registered (and thus applied) prior to those specified in the connection URL.

        See Also:
        Constant Field Values
      • PARAM_POST_PROCESSOR

        public static final java.lang.String PARAM_POST_PROCESSOR
        Constant for the connection URL parameter used to set class names of ResultsPostProcessor implementations to use with returned connections.

        This parameter may be specified multiple times and post-processors will be registered (and thus applied) in the order specified. If any post-processors are passed as part of the Properties object rather than in the connection URL then these will be registered (and thus applied) prior to those specified in the connection URL.

        See Also:
        Constant Field Values
      • PARAM_USERNAME

        public static final java.lang.String PARAM_USERNAME
        Constant for the standard JDBC connection URL parameter used to set user name for drivers that support authentication
        See Also:
        Constant Field Values
      • PARAM_PASSWORD

        public static final java.lang.String PARAM_PASSWORD
        Constant for the standard JDBC connection URL parameter used to set password for drivers that support authentication
        See Also:
        Constant Field Values
      • PARAM_LOGGING

        @Deprecated
        public static final java.lang.String PARAM_LOGGING
        Deprecated.
        No longer supported as of Jena 4.x
        Old connection URL property for having the driver configure logging, no longer supported as of Jena 4.x
        See Also:
        Constant Field Values
      • NO_AUTO_LOGGING_CONFIGURATION

        @Deprecated
        public static final java.lang.String NO_AUTO_LOGGING_CONFIGURATION
        Deprecated.
        Constant for the special value used with the PARAM_LOGGING parameter to indicate that the user code will manage configuration of logging. This is also the default value when that parameter is not set.
        See Also:
        Constant Field Values
      • PARAM_CONFIG

        public static final java.lang.String PARAM_CONFIG
        Constant for the connection URL parameter used to set the path to a Java properties file used to provide additional connection parameters external to the URL. This is useful when you want to have a single connection string and pick up different configurations depending on where the driver is used.

        Just like the PARAM_LOGGING parameter the file system is searched before the class path. Also note that this is the first parameter that is honored so settings present in the properties file may be overridden by those explicitly provided in the connection URL or those given in the Properties object passed to the Driver.connect(String, Properties) method.

        If you specify this parameter in both the connection URL and the Properties object then the latter takes precedence and the former is ignored. It is also important to note that this is not transitively resolved i.e. if the referenced property file includes a config parameter it does not result in a further properties file/files being loaded.

        See Also:
        Constant Field Values
    • Constructor Detail

      • JenaDriver

        public JenaDriver​(int majorVer,
                          int minorVer,
                          java.lang.String prefix)
        Creates a new driver
        Parameters:
        majorVer - Major Version
        minorVer - Minor Version
        prefix - Implementation specific prefix which must end with a colon
    • Method Detail

      • acceptsURL

        public boolean acceptsURL​(java.lang.String url)
        Specified by:
        acceptsURL in interface java.sql.Driver
      • connect

        public final java.sql.Connection connect​(java.lang.String url,
                                                 java.util.Properties props)
                                          throws java.sql.SQLException
        Specified by:
        connect in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • getMajorVersion

        public int getMajorVersion()
        Specified by:
        getMajorVersion in interface java.sql.Driver
      • getMinorVersion

        public int getMinorVersion()
        Specified by:
        getMinorVersion in interface java.sql.Driver
      • getPropertyInfo

        public final java.sql.DriverPropertyInfo[] getPropertyInfo​(java.lang.String url,
                                                                   java.util.Properties props)
                                                            throws java.sql.SQLException
        Specified by:
        getPropertyInfo in interface java.sql.Driver
        Throws:
        java.sql.SQLException
      • jdbcCompliant

        public final boolean jdbcCompliant()
        Returns that a Jena JDBC driver is not JDBC compliant since strict JDBC compliance requires support for SQL-92 and since we are using SPARQL we don't meet that criteria
        Specified by:
        jdbcCompliant in interface java.sql.Driver
      • getParentLogger

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