Java Code Examples for java.sql.DriverPropertyInfo

The following examples show how to use java.sql.DriverPropertyInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spanner-jdbc   Source File: CloudSpannerDriverTest.java    License: MIT License 6 votes vote down vote up
@Test
public void driverPropertyInfoWithoutValues() throws SQLException {
  Driver driver = getDriver();
  DriverPropertyInfo[] properties =
      driver.getPropertyInfo("jdbc:cloudspanner://localhost", null);
  assertEquals(ConnectionProperties.NUMBER_OF_PROPERTIES, properties.length);
  for (DriverPropertyInfo property : properties) {
    if (property.name.equals("AllowExtendedMode") || property.name.equals("AsyncDdlOperations")
        || property.name.equals("AutoBatchDdlOperations")
        || property.name.equals("BatchReadOnlyMode") || property.name.equals("UseCustomHost"))
      assertEquals("false", property.value);
    else if (property.name.equals("ReportDefaultSchemaAsNull"))
      assertEquals("true", property.value);
    else
      assertNull(property.value);
  }
}
 
Example 2
Source Project: r-course   Source File: MetaDataRegressionTest.java    License: MIT License 6 votes vote down vote up
/**
 * Fix for BUG#22628 - Driver.getPropertyInfo() throws NullPointerException
 * for URL that only specifies host and/or port.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug22628() throws Exception {
    DriverPropertyInfo[] dpi = new NonRegisteringDriver().getPropertyInfo("jdbc:mysql://bogus:9999", new Properties());

    boolean foundHost = false;
    boolean foundPort = false;

    for (int i = 0; i < dpi.length; i++) {
        if ("bogus".equals(dpi[i].value)) {
            foundHost = true;
        }

        if ("9999".equals(dpi[i].value)) {
            foundPort = true;
        }
    }

    assertTrue(foundHost && foundPort);
}
 
Example 3
Source Project: calcite-avatica   Source File: UnregisteredDriver.java    License: Apache License 2.0 6 votes vote down vote up
public DriverPropertyInfo[] getPropertyInfo(
    String url, Properties info) throws SQLException {
  List<DriverPropertyInfo> list = new ArrayList<DriverPropertyInfo>();

  // First, add the contents of info
  for (Map.Entry<Object, Object> entry : info.entrySet()) {
    list.add(
        new DriverPropertyInfo(
            (String) entry.getKey(),
            (String) entry.getValue()));
  }
  // Next, add property definitions not mentioned in info
  for (ConnectionProperty p : getConnectionProperties()) {
    if (info.containsKey(p.name())) {
      continue;
    }
    list.add(new DriverPropertyInfo(p.name(), null));
  }
  return list.toArray(new DriverPropertyInfo[list.size()]);
}
 
Example 4
Source Project: presto   Source File: PrestoDriver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
        throws SQLException
{
    Properties properties = new PrestoDriverUri(url, info).getProperties();

    return ConnectionProperties.allProperties().stream()
            .map(property -> property.getDriverPropertyInfo(properties))
            .toArray(DriverPropertyInfo[]::new);
}
 
Example 5
Source Project: presto   Source File: AbstractConnectionProperty.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DriverPropertyInfo getDriverPropertyInfo(Properties mergedProperties)
{
    String currentValue = mergedProperties.getProperty(key);
    DriverPropertyInfo result = new DriverPropertyInfo(key, currentValue);
    result.required = isRequired.test(mergedProperties);
    return result;
}
 
Example 6
Source Project: olaper   Source File: OlapServerDriver.java    License: MIT License 5 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
		throws SQLException {
       List<DriverPropertyInfo> list = new ArrayList<DriverPropertyInfo>();
       for (Map.Entry<Object, Object> entry : info.entrySet()) {
           list.add(
               new DriverPropertyInfo(
                   (String) entry.getKey(),
                   (String) entry.getValue()));
       }
       return list.toArray(new DriverPropertyInfo[list.size()]);

}
 
Example 7
Source Project: spanner-jdbc   Source File: CloudSpannerDriver.java    License: MIT License 5 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
  if (!acceptsURL(url))
    return new DriverPropertyInfo[0];
  ConnectionProperties properties = ConnectionProperties.parse(url);
  properties.setAdditionalConnectionProperties(info);

  return properties.getPropertyInfo();
}
 
Example 8
Source Project: spanner-jdbc   Source File: CloudSpannerDriverTest.java    License: MIT License 5 votes vote down vote up
@Test
public void driverPropertyInfoWithURLValues() throws SQLException {
  Driver driver = getDriver();
  DriverPropertyInfo[] properties = driver.getPropertyInfo(
      "jdbc:cloudspanner://localhost;Project=adroit-hall-xxx;Instance=test-instance;Database=testdb;PvtKeyPath=C:\\Users\\MyUserName\\Documents\\CloudSpannerKeys\\cloudspanner3.json;SimulateProductName=PostgreSQL",
      null);
  assertEquals(ConnectionProperties.NUMBER_OF_PROPERTIES, properties.length);
  assertEquals("adroit-hall-xxx", properties[0].value);
  assertEquals("test-instance", properties[1].value);
  assertEquals("testdb", properties[2].value);
  assertEquals("C:\\Users\\MyUserName\\Documents\\CloudSpannerKeys\\cloudspanner3.json",
      properties[3].value);
  assertNull(properties[4].value);
  assertEquals("PostgreSQL", properties[5].value);
}
 
Example 9
Source Project: lams   Source File: JdbcPropertySetImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
private DriverPropertyInfo getAsDriverPropertyInfo(ReadableProperty<?> pr) {
    PropertyDefinition<?> pdef = pr.getPropertyDefinition();

    DriverPropertyInfo dpi = new DriverPropertyInfo(pdef.getName(), null);
    dpi.choices = pdef.getAllowableValues();
    dpi.value = (pr.getStringValue() != null) ? pr.getStringValue() : null;
    dpi.required = false;
    dpi.description = pdef.getDescription();

    return dpi;
}
 
Example 10
public DriverPropertyInfo[] getPropertyInfo()
{
	ArrayList<DriverPropertyInfo> propInfos = new ArrayList<DriverPropertyInfo>();

	addPropInfo(
		propInfos,
		AUTO_CONNECT_RETRY,
		"false",
		"If true, the driver will keep trying to connect to the same server in case that the socket "
			+ "cannot be established. There is maximum amount of time to keep retrying, which is 15s by "
			+ "default.", null);

	addPropInfo(propInfos, CONNECTIONS_PER_HOST, "10", "The maximum number of connections allowed per "
		+ "host for this Mongo instance. Those connections will be kept in a pool when idle.", null);

	addPropInfo(propInfos, CONNECT_TIMEOUT, "10000", "The connection timeout in milliseconds. ", null);

	addPropInfo(propInfos, CURSOR_FINALIZER_ENABLED, "true", "Sets whether there is a a finalize "
		+ "method created that cleans up instances of DBCursor that the client does not close.",
		null);

	addPropInfo(propInfos, MAX_AUTO_CONNECT_RETRY_TIME, "0",
		"The maximum amount of time in MS to spend retrying to open connection to the same server."
			+ "Default is 0, which means to use the default 15s if autoConnectRetry is on.", null);

	addPropInfo(propInfos, READ_PREFERENCE, "primary",
		"represents preferred replica set members to which a query or command can be sent", new String[] {
				"primary", "primary preferred", "secondary", "secondary preferred", "nearest" });

	addPropInfo(propInfos, SOCKET_TIMEOUT, "0", "The socket timeout in milliseconds It is used for "
		+ "I/O socket read and write operations "
		+ "Socket.setSoTimeout(int) Default is 0 and means no timeout.", null);

	return propInfos.toArray(new DriverPropertyInfo[propInfos.size()]);
}
 
Example 11
private void addPropInfo(final ArrayList<DriverPropertyInfo> propInfos, final String propName,
	final String defaultVal, final String description, final String[] choices)
{
	DriverPropertyInfo newProp = new DriverPropertyInfo(propName, defaultVal);
	newProp.description = description;
	if (choices != null)
	{
		newProp.choices = choices;
	}
	propInfos.add(newProp);
}
 
Example 12
public DriverPropertyInfo[] getPropertyInfo()
{
	ArrayList<DriverPropertyInfo> propInfos = new ArrayList<DriverPropertyInfo>();

	addPropInfo(
		propInfos,
		AUTO_CONNECT_RETRY,
		"false",
		"If true, the driver will keep trying to connect to the same server in case that the socket "
			+ "cannot be established. There is maximum amount of time to keep retrying, which is 15s by "
			+ "default.", null);

	addPropInfo(propInfos, CONNECTIONS_PER_HOST, "10", "The maximum number of connections allowed per "
		+ "host for this Mongo instance. Those connections will be kept in a pool when idle.", null);

	addPropInfo(propInfos, CONNECT_TIMEOUT, "10000", "The connection timeout in milliseconds. ", null);

	addPropInfo(propInfos, CURSOR_FINALIZER_ENABLED, "true", "Sets whether there is a a finalize "
		+ "method created that cleans up instances of DBCursor that the client does not close.",
		null);

	addPropInfo(propInfos, MAX_AUTO_CONNECT_RETRY_TIME, "0",
		"The maximum amount of time in MS to spend retrying to open connection to the same server."
			+ "Default is 0, which means to use the default 15s if autoConnectRetry is on.", null);

	addPropInfo(propInfos, READ_PREFERENCE, "primary",
		"represents preferred replica set members to which a query or command can be sent", new String[] {
				"primary", "primary preferred", "secondary", "secondary preferred", "nearest" });

	addPropInfo(propInfos, SOCKET_TIMEOUT, "0", "The socket timeout in milliseconds It is used for "
		+ "I/O socket read and write operations "
		+ "Socket.setSoTimeout(int) Default is 0 and means no timeout.", null);

	return propInfos.toArray(new DriverPropertyInfo[propInfos.size()]);
}
 
Example 13
private void addPropInfo(final ArrayList<DriverPropertyInfo> propInfos, final String propName,
	final String defaultVal, final String description, final String[] choices)
{
	DriverPropertyInfo newProp = new DriverPropertyInfo(propName, defaultVal);
	newProp.description = description;
	if (choices != null)
	{
		newProp.choices = choices;
	}
	propInfos.add(newProp);
}
 
Example 14
Source Project: r-course   Source File: ConnectionPropertiesImpl.java    License: MIT License 5 votes vote down vote up
DriverPropertyInfo getAsDriverPropertyInfo() {
    DriverPropertyInfo dpi = new DriverPropertyInfo(this.propertyName, null);
    dpi.choices = getAllowableValues();
    dpi.value = (this.valueAsObject != null) ? this.valueAsObject.toString() : null;
    dpi.required = this.required;
    dpi.description = this.description;

    return dpi;
}
 
Example 15
Source Project: r-course   Source File: ConnectionPropertiesImpl.java    License: MIT License 5 votes vote down vote up
protected DriverPropertyInfo[] exposeAsDriverPropertyInfoInternal(Properties info, int slotsToReserve) throws SQLException {
    initializeProperties(info);

    int numProperties = PROPERTY_LIST.size();

    int listSize = numProperties + slotsToReserve;

    DriverPropertyInfo[] driverProperties = new DriverPropertyInfo[listSize];

    for (int i = slotsToReserve; i < listSize; i++) {
        java.lang.reflect.Field propertyField = PROPERTY_LIST.get(i - slotsToReserve);

        try {
            ConnectionProperty propToExpose = (ConnectionProperty) propertyField.get(this);

            if (info != null) {
                propToExpose.initializeFrom(info, getExceptionInterceptor());
            }

            driverProperties[i] = propToExpose.getAsDriverPropertyInfo();
        } catch (IllegalAccessException iae) {
            throw SQLError.createSQLException(Messages.getString("ConnectionProperties.InternalPropertiesFailure"), SQLError.SQL_STATE_GENERAL_ERROR,
                    getExceptionInterceptor());
        }
    }

    return driverProperties;
}
 
Example 16
Source Project: dremio-oss   Source File: InvocationReporterImpl.java    License: Apache License 2.0 5 votes vote down vote up
private String formatDriverPropertyInfo( final DriverPropertyInfo info ) {
  return
      "[ "
      + "name = " + formatValue( info.name )
      + ", value = " + formatValue( info.value )
      + ", required = " + info.required
      + ", choices = " + formatValue( info.choices )
      + ", description = " + formatValue( info.description )
      + " ]";
}
 
Example 17
Source Project: sql4es   Source File: ESDriver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
	Properties props = (Properties)parseURL(url, info)[3];
	DriverPropertyInfo[] result = new DriverPropertyInfo[props.size()];
	int index = 0;
	for(Map.Entry<Object,Object> entry : props.entrySet()){
		result[index] = new DriverPropertyInfo((String)entry.getKey(), entry.getValue().toString());
		index++;
	}
	return result;
}
 
Example 18
DriverPropertyInfo getAsDriverPropertyInfo() {
    DriverPropertyInfo dpi = new DriverPropertyInfo(this.propertyName, null);
    dpi.choices = getAllowableValues();
    dpi.value = (this.valueAsObject != null) ? this.valueAsObject.toString() : null;
    dpi.required = this.required;
    dpi.description = this.description;

    return dpi;
}
 
Example 19
protected DriverPropertyInfo[] exposeAsDriverPropertyInfoInternal(Properties info, int slotsToReserve) throws SQLException {
    initializeProperties(info);

    int numProperties = PROPERTY_LIST.size();

    int listSize = numProperties + slotsToReserve;

    DriverPropertyInfo[] driverProperties = new DriverPropertyInfo[listSize];

    for (int i = slotsToReserve; i < listSize; i++) {
        java.lang.reflect.Field propertyField = PROPERTY_LIST.get(i - slotsToReserve);

        try {
            ConnectionProperty propToExpose = (ConnectionProperty) propertyField.get(this);

            if (info != null) {
                propToExpose.initializeFrom(info, getExceptionInterceptor());
            }

            driverProperties[i] = propToExpose.getAsDriverPropertyInfo();
        } catch (IllegalAccessException iae) {
            throw SQLError.createSQLException(Messages.getString("ConnectionProperties.InternalPropertiesFailure"), SQLError.SQL_STATE_GENERAL_ERROR,
                    getExceptionInterceptor());
        }
    }

    return driverProperties;
}
 
Example 20
Source Project: Tomcat8-Source-Read   Source File: PoolingDriver.java    License: MIT License 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
    return new DriverPropertyInfo[0];
}
 
Example 21
Source Project: Tomcat8-Source-Read   Source File: TestSlowQueryReport.java    License: MIT License 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
Example 22
Source Project: Tomcat8-Source-Read   Source File: TestValidation.java    License: MIT License 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
Example 23
Source Project: Tomcat8-Source-Read   Source File: Driver.java    License: MIT License 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
Example 24
Source Project: Tomcat8-Source-Read   Source File: TestValidationQueryTimeout.java    License: MIT License 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
Example 25
Source Project: micro-integrator   Source File: TDriver.java    License: Apache License 2.0 4 votes vote down vote up
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return new DriverPropertyInfo[0];
}
 
Example 26
Source Project: presto   Source File: ForwardingDriver.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
        throws SQLException
{
    return driver.getPropertyInfo(url, info);
}
 
Example 27
Source Project: camel-spring-boot   Source File: DummyJDBCDriver.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String s, Properties properties) throws SQLException {
    return new DriverPropertyInfo[0];
}
 
Example 28
Source Project: hop   Source File: DelegatingDriver.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo( String url, Properties info ) throws SQLException {
  return driver.getPropertyInfo( url, info );
}
 
Example 29
Source Project: dragonwell8_jdk   Source File: StubDriver.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 30
Source Project: TencentKona-8   Source File: StubDriver.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}