类java.sql.DriverPropertyInfo源码实例Demo

下面列出了怎么用java.sql.DriverPropertyInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spanner-jdbc   文件: CloudSpannerDriverTest.java
@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);
  }
}
 
源代码2 项目: r-course   文件: MetaDataRegressionTest.java
/**
 * 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);
}
 
源代码3 项目: calcite-avatica   文件: UnregisteredDriver.java
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()]);
}
 
源代码4 项目: presto   文件: PrestoDriver.java
@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);
}
 
源代码5 项目: presto   文件: AbstractConnectionProperty.java
@Override
public DriverPropertyInfo getDriverPropertyInfo(Properties mergedProperties)
{
    String currentValue = mergedProperties.getProperty(key);
    DriverPropertyInfo result = new DriverPropertyInfo(key, currentValue);
    result.required = isRequired.test(mergedProperties);
    return result;
}
 
源代码6 项目: olaper   文件: OlapServerDriver.java
@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()]);

}
 
源代码7 项目: spanner-jdbc   文件: CloudSpannerDriver.java
@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();
}
 
源代码8 项目: spanner-jdbc   文件: CloudSpannerDriverTest.java
@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);
}
 
源代码9 项目: lams   文件: JdbcPropertySetImpl.java
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;
}
 
源代码10 项目: Mycat2   文件: DriverPropertyInfoHelper.java
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()]);
}
 
源代码11 项目: Mycat2   文件: DriverPropertyInfoHelper.java
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);
}
 
源代码12 项目: Mycat2   文件: DriverPropertyInfoHelper.java
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()]);
}
 
源代码13 项目: Mycat2   文件: DriverPropertyInfoHelper.java
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);
}
 
源代码14 项目: r-course   文件: ConnectionPropertiesImpl.java
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;
}
 
源代码15 项目: r-course   文件: ConnectionPropertiesImpl.java
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;
}
 
源代码16 项目: dremio-oss   文件: InvocationReporterImpl.java
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 )
      + " ]";
}
 
源代码17 项目: sql4es   文件: ESDriver.java
@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;
}
 
源代码18 项目: Komondor   文件: ConnectionPropertiesImpl.java
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;
}
 
源代码19 项目: Komondor   文件: ConnectionPropertiesImpl.java
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;
}
 
源代码20 项目: Tomcat8-Source-Read   文件: PoolingDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
    return new DriverPropertyInfo[0];
}
 
源代码21 项目: Tomcat8-Source-Read   文件: TestSlowQueryReport.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
源代码22 项目: Tomcat8-Source-Read   文件: TestValidation.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
源代码23 项目: Tomcat8-Source-Read   文件: Driver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return null;
}
 
源代码25 项目: micro-integrator   文件: TDriver.java
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    return new DriverPropertyInfo[0];
}
 
源代码26 项目: presto   文件: ForwardingDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
        throws SQLException
{
    return driver.getPropertyInfo(url, info);
}
 
源代码27 项目: camel-spring-boot   文件: DummyJDBCDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String s, Properties properties) throws SQLException {
    return new DriverPropertyInfo[0];
}
 
源代码28 项目: hop   文件: DelegatingDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo( String url, Properties info ) throws SQLException {
  return driver.getPropertyInfo( url, info );
}
 
源代码29 项目: dragonwell8_jdk   文件: StubDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
源代码30 项目: TencentKona-8   文件: StubDriver.java
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}