public final Connection connect(String url, Properties props) throws SQLException { if (!this.acceptsURL(url)) return null; Properties ps = this.getEffectiveProperties(url, props); this.modifyProperties(ps); try { conn = this.connect(ps, compatibilityLevel);
if ( this.allowsMultipleValues( key ) ) else if ( this.allowsMultipleValues( key ) ) Properties external = this.loadProperties(props.getProperty(PARAM_CONFIG)); LOGGER.info("Merging in external properties file " + props.getProperty(PARAM_CONFIG)); this.mergeProperties(external, ps, false); } else if (ps.containsKey(PARAM_CONFIG)) { Properties external = this.loadProperties(ps.getProperty(PARAM_CONFIG)); LOGGER.info("Merging in external properties file " + ps.getProperty(PARAM_CONFIG)); this.mergeProperties(external, ps, false); this.mergeProperties(props, ps, true);
public final DriverPropertyInfo[] getPropertyInfo(String url, Properties props) throws SQLException { Properties ps = this.getEffectiveProperties(url, props); // Create base driver properties List<DriverPropertyInfo> baseProps = new ArrayList<>(); // JDBC compatibility level DriverPropertyInfo jdbcCompatLevel = new DriverPropertyInfo(PARAM_JDBC_COMPATIBILITY, ps.getProperty( PARAM_JDBC_COMPATIBILITY, Integer.toString(JdbcCompatibility.DEFAULT))); jdbcCompatLevel.description = "Configures how compatible the driver will attempt to be with JDBC, primarily affects reported column types for result sets"; jdbcCompatLevel.required = false; String[] choices = new String[9]; for (int i = 0; i < choices.length; i++) { choices[i] = Integer.toString(i + 1); } jdbcCompatLevel.choices = choices; baseProps.add(jdbcCompatLevel); // Pre-processors DriverPropertyInfo preProcessor = new DriverPropertyInfo(PARAM_PRE_PROCESSOR, String.join(",", this.getValues(ps, PARAM_PRE_PROCESSOR))); preProcessor.description = "Configures pre-processors which are used to amend SPARQL text, queries or updates before these are passed to the underlying SPARQL engine, multiple fully qualified class names may be specified"; preProcessor.required = false; baseProps.add(preProcessor); // Logging config DriverPropertyInfo logging = new DriverPropertyInfo(PARAM_LOGGING, ps.getProperty(PARAM_LOGGING)); logging.description = "Sets the path to a log4j properties file for configuring logging, the file system is considered first and then the classpath. If not set defaults to log4j.properties"; logging.required = false; baseProps.add(logging); // Have the derived implementation create the final property information return this.getPropertyInfo(ps, baseProps); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard pre-processor parameter but setting the pre-processor to a value * that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_03() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that exists but isn't a CommandPreProcessor url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Node.class.getCanonicalName(); JenaDriver driver = this.getDriver(); driver.connect(url, null); }
@Override protected boolean allowsMultipleValues(String key) { if (PARAM_DEFAULT_GRAPH_URI.equals(key) || PARAM_NAMED_GRAPH_URI.equals(key) || PARAM_USING_GRAPH_URI.equals(key) || PARAM_USING_NAMED_GRAPH_URI.equals(key)) { return true; } else { return super.allowsMultipleValues(key); } }
/** * Tests that an implementation will not accept an arbitrary URL * * @throws SQLException */ @Test public void driver_accepts_02() throws SQLException { String url = "jdbc:unknown:http://example.org"; JenaDriver driver = this.getDriver(); Assert.assertFalse(driver.acceptsURL(url)); }
/** * Tests using a driver to create a connection with its own URLs plus the * standard post-processor parameter but setting the post-processor to a * value that creates an error * * @throws SQLException */ @Test(expected = SQLException.class) public void driver_connect_bad_05() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); // Try to use a class that exists but isn't a ResultsPostProcessor url = url + "&" + JenaDriver.PARAM_POST_PROCESSOR + "=" + Node.class.getCanonicalName(); JenaDriver driver = this.getDriver(); driver.connect(url, null); }
if (this.allowsMultipleValues(key)) {
/** * Test that an implementation will accept its own URLs * * @throws SQLException */ @Test public void driver_accepts_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); Assert.assertTrue(driver.acceptsURL(url)); }
JenaDriver driver = this.getDriver(); JenaConnection conn = (JenaConnection) driver.connect(url, null); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
public final Connection connect(String url, Properties props) throws SQLException { if (!this.acceptsURL(url)) return null; Properties ps = this.getEffectiveProperties(url, props); this.modifyProperties(ps); try { conn = this.connect(ps, compatibilityLevel);
if ( this.allowsMultipleValues( key ) ) else if ( this.allowsMultipleValues( key ) ) Properties external = this.loadProperties(props.getProperty(PARAM_CONFIG)); LOGGER.info("Merging in external properties file " + props.getProperty(PARAM_CONFIG)); this.mergeProperties(external, ps, false); } else if (ps.containsKey(PARAM_CONFIG)) { Properties external = this.loadProperties(ps.getProperty(PARAM_CONFIG)); LOGGER.info("Merging in external properties file " + ps.getProperty(PARAM_CONFIG)); this.mergeProperties(external, ps, false); this.mergeProperties(props, ps, true);
if (this.allowsMultipleValues(key)) {
public final DriverPropertyInfo[] getPropertyInfo(String url, Properties props) throws SQLException { Properties ps = this.getEffectiveProperties(url, props); // Create base driver properties List<DriverPropertyInfo> baseProps = new ArrayList<>(); // JDBC compatibility level DriverPropertyInfo jdbcCompatLevel = new DriverPropertyInfo(PARAM_JDBC_COMPATIBILITY, ps.getProperty( PARAM_JDBC_COMPATIBILITY, Integer.toString(JdbcCompatibility.DEFAULT))); jdbcCompatLevel.description = "Configures how compatible the driver will attempt to be with JDBC, primarily affects reported column types for result sets"; jdbcCompatLevel.required = false; String[] choices = new String[9]; for (int i = 0; i < choices.length; i++) { choices[i] = Integer.toString(i + 1); } jdbcCompatLevel.choices = choices; baseProps.add(jdbcCompatLevel); // Pre-processors DriverPropertyInfo preProcessor = new DriverPropertyInfo(PARAM_PRE_PROCESSOR, String.join(",", this.getValues(ps, PARAM_PRE_PROCESSOR))); preProcessor.description = "Configures pre-processors which are used to amend SPARQL text, queries or updates before these are passed to the underlying SPARQL engine, multiple fully qualified class names may be specified"; preProcessor.required = false; baseProps.add(preProcessor); // Logging config DriverPropertyInfo logging = new DriverPropertyInfo(PARAM_LOGGING, ps.getProperty(PARAM_LOGGING)); logging.description = "Sets the path to a log4j properties file for configuring logging, the file system is considered first and then the classpath. If not set defaults to log4j.properties"; logging.required = false; baseProps.add(logging); // Have the derived implementation create the final property information return this.getPropertyInfo(ps, baseProps); }
/** * Tests using a driver to create a connection with its own URLs * * @throws SQLException */ @Test public void driver_connect_01() throws SQLException { String url = this.getConnectionUrl(); Assume.assumeNotNull(url); JenaDriver driver = this.getDriver(); Connection conn = driver.connect(url, null); Assert.assertFalse(conn.isClosed()); conn.close(); Assert.assertTrue(conn.isClosed()); }
if (this.allowsMultipleValues(key)) { Object currValue = e.getValue(); if (currValue instanceof String) {
ps.put(JenaDriver.PARAM_CONFIG, f2.getAbsolutePath()); JenaConnection conn = (JenaConnection) driver.connect(url, ps); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
if (this.allowsMultipleValues(key)) { Object currValue = e.getValue(); if (currValue instanceof String) {
ps.put("test", "props"); JenaConnection conn = (JenaConnection) driver.connect(url, ps); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());
JenaConnection conn = (JenaConnection) driver.connect(url, ps); Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors(); Assert.assertTrue(preProcessors.hasNext());