use of java.sql.DriverPropertyInfo in project dbeaver by serge-rider.
the class JDBCDataSourceProvider method readDriverProperties.
private Collection<DBPPropertyDescriptor> readDriverProperties(DBPConnectionConfiguration connectionInfo, Driver driver) throws DBException {
Properties driverProps = new Properties();
//driverProps.putAll(connectionInfo.getProperties());
DriverPropertyInfo[] propDescs;
try {
propDescs = driver.getPropertyInfo(connectionInfo.getUrl(), driverProps);
} catch (Throwable e) {
//$NON-NLS-1$
log.debug("Cannot obtain driver's properties", e);
return null;
}
if (propDescs == null) {
return null;
}
List<DBPPropertyDescriptor> properties = new ArrayList<>();
for (DriverPropertyInfo desc : propDescs) {
if (desc == null || DBConstants.DATA_SOURCE_PROPERTY_USER.equals(desc.name) || DBConstants.DATA_SOURCE_PROPERTY_PASSWORD.equals(desc.name)) {
// Skip user/password properties
continue;
}
desc.value = getConnectionPropertyDefaultValue(desc.name, desc.value);
properties.add(new PropertyDescriptor(ModelMessages.model_jdbc_driver_properties, desc.name, desc.name, desc.description, String.class, desc.required, desc.value, desc.choices, true));
}
return properties;
}
use of java.sql.DriverPropertyInfo in project jena by apache.
the class JenaDriver method getPropertyInfo.
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);
}
use of java.sql.DriverPropertyInfo in project jena by apache.
the class RemoteEndpointDriver method getPropertyInfo.
@Override
protected DriverPropertyInfo[] getPropertyInfo(Properties connProps, List<DriverPropertyInfo> baseDriverProps) {
DriverPropertyInfo[] driverProps = new DriverPropertyInfo[10 + baseDriverProps.size()];
this.copyBaseProperties(driverProps, baseDriverProps, 10);
// Query Endpoint parameter
driverProps[0] = new DriverPropertyInfo(PARAM_QUERY_ENDPOINT, connProps.getProperty(PARAM_QUERY_ENDPOINT));
driverProps[0].required = !connProps.containsKey(PARAM_UPDATE_ENDPOINT);
driverProps[0].description = "Sets the SPARQL Query endpoint to use for query operations, if this is specified and " + PARAM_UPDATE_ENDPOINT + " is not then a read-only connection will be created";
// Update Endpoint parameter
driverProps[1] = new DriverPropertyInfo(PARAM_UPDATE_ENDPOINT, connProps.getProperty(PARAM_UPDATE_ENDPOINT));
driverProps[1].required = !connProps.containsKey(PARAM_UPDATE_ENDPOINT);
driverProps[1].description = "Sets the SPARQL Update endpoint to use for update operations, if this is specified and " + PARAM_QUERY_ENDPOINT + " is not then a write-only connection will be created";
// Default Graph parameter
driverProps[2] = new DriverPropertyInfo(PARAM_DEFAULT_GRAPH_URI, null);
driverProps[2].required = false;
driverProps[2].description = "Sets the URI for a default graph for queries, may be specified multiple times to specify multiple graphs which should form the default graph";
// Named Graph parameter
driverProps[3] = new DriverPropertyInfo(PARAM_NAMED_GRAPH_URI, null);
driverProps[3].required = false;
driverProps[3].description = "Sets the URI for a named graph for queries, may be specified multiple times to specify multiple named graphs which should be accessible";
// Using Graph parameter
driverProps[4] = new DriverPropertyInfo(PARAM_USING_GRAPH_URI, null);
driverProps[4].required = false;
driverProps[4].description = "Sets the URI for a default graph for updates, may be specified multiple times to specify multiple graphs which should form the default graph";
// Using Named Graph parameter
driverProps[5] = new DriverPropertyInfo(PARAM_USING_NAMED_GRAPH_URI, null);
driverProps[5].required = false;
driverProps[5].description = "Sets the URI for a named graph for updates, may be specified multiple times to specify multiple named graph which should be accessible";
// Results Types
driverProps[6] = new DriverPropertyInfo(PARAM_SELECT_RESULTS_TYPE, connProps.getProperty(PARAM_SELECT_RESULTS_TYPE));
driverProps[6].required = false;
driverProps[6].description = "Sets the results type for SELECT queries that will be requested from the remote endpoint";
driverProps[7] = new DriverPropertyInfo(PARAM_MODEL_RESULTS_TYPE, connProps.getProperty(PARAM_MODEL_RESULTS_TYPE));
driverProps[7].required = false;
driverProps[7].description = "Sets the results type for CONSTRUCT and DESCRIBE queries that will be requested from the remote endpoint";
// User Name parameter
driverProps[8] = new DriverPropertyInfo(PARAM_USERNAME, connProps.getProperty(PARAM_USERNAME));
// Password parameter
driverProps[9] = new DriverPropertyInfo(PARAM_PASSWORD, connProps.getProperty(PARAM_PASSWORD));
return driverProps;
}
use of java.sql.DriverPropertyInfo in project jena by apache.
the class TDBDriver method getPropertyInfo.
@Override
protected DriverPropertyInfo[] getPropertyInfo(Properties connProps, List<DriverPropertyInfo> baseDriverProps) {
DriverPropertyInfo[] driverProps = new DriverPropertyInfo[2 + baseDriverProps.size()];
this.copyBaseProperties(driverProps, baseDriverProps, 2);
// Location parameter
driverProps[0] = new DriverPropertyInfo(PARAM_LOCATION, connProps.getProperty(PARAM_LOCATION));
driverProps[0].required = true;
driverProps[0].description = "Sets the location of a TDB dataset, should be a file system path. The value " + LOCATION_MEM + " may be used for a non-persistent in-memory dataset but this should only be used for testing";
// Must Exist parameter
driverProps[1] = new DriverPropertyInfo(PARAM_MUST_EXIST, connProps.getProperty(PARAM_MUST_EXIST));
driverProps[1].required = false;
driverProps[1].choices = new String[] { "true", "false" };
driverProps[1].description = "If set to true requests that the driver check whether the " + PARAM_LOCATION + " parameter refers to an existing location before establishing a connection";
return driverProps;
}
use of java.sql.DriverPropertyInfo in project voltdb by VoltDB.
the class JDBCDriver method getPropertyInfo.
/**
* Gets information about the possible properties for this driver. <p>
*
* The getPropertyInfo method is intended to allow a generic GUI tool
* to discover what properties it should prompt a human for in order to
* get enough information to connect to a database. Note that depending
* on the values the human has supplied so far, additional values may
* become necessary, so it may be necessary to iterate though several
* calls to getPropertyInfo.<p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:</h3> <p>
*
* HSQLDB uses the values submitted in info to set the value for
* each DriverPropertyInfo object returned. It does not use the default
* value that it would use for the property if the value is null. <p>
*
* </div> <!-- end release-specific documentation -->
*
* @param url the URL of the database to which to connect
* @param info a proposed list of tag/value pairs that will be sent on
* connect open
* @return an array of DriverPropertyInfo objects describing possible
* properties. This array may be an empty array if no properties
* are required.
*/
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
if (!acceptsURL(url)) {
return new DriverPropertyInfo[0];
}
String[] choices = new String[] { "true", "false" };
DriverPropertyInfo[] pinfo = new DriverPropertyInfo[6];
DriverPropertyInfo p;
if (info == null) {
info = new Properties();
}
p = new DriverPropertyInfo("user", null);
p.value = info.getProperty("user");
p.required = true;
pinfo[0] = p;
p = new DriverPropertyInfo("password", null);
p.value = info.getProperty("password");
p.required = true;
pinfo[1] = p;
p = new DriverPropertyInfo("get_column_name", null);
p.value = info.getProperty("get_column_name", "true");
p.required = false;
p.choices = choices;
pinfo[2] = p;
p = new DriverPropertyInfo("ifexists", null);
p.value = info.getProperty("ifexists", "false");
p.required = false;
p.choices = choices;
pinfo[3] = p;
p = new DriverPropertyInfo("default_schema", null);
p.value = info.getProperty("default_schema", "false");
p.required = false;
p.choices = choices;
pinfo[4] = p;
p = new DriverPropertyInfo("shutdown", null);
p.value = info.getProperty("shutdown", "false");
p.required = false;
p.choices = choices;
pinfo[5] = p;
return pinfo;
}
Aggregations