Class AceQLDriver
- All Implemented Interfaces:
Driver
public final class AceQLDriver extends Object implements Driver
user, password and database are the only required properties.
Properties:
- user: username to connect to the remote database as.
- password: password to use when authenticating.
- database: name of remote database as defined in the server
aceql-server.propertiesfile. - proxyType: java.net.Proxy Type to use: DIRECT, HTTP or SOCKS. Defaults to DIRECT.
- proxyHostname: java.net.Proxy hostname to use.
- proxyPort: java.net.Proxy Port to use.
- proxyUsername: Proxy credential username.
- proxyPassword: Proxy credential password.
- connectTimeout: Timeout value, in milliseconds, to be used when opening a communications link to the remote server. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. Defaults to 0.
- readTimeout: Read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout. Defaults to 0.
- gzipResult: Boolean to say if the ResultSet is Gzipped before
download. Defaults to
true. - resultSetMetaDataPolicy: Defines the
ResultSetmetadata policy. Says if theResultSetmetadata is to be downloaded along with the ResultSet. Possible values are "on" and "off". Defaults to "on". - clobReadCharset: Name of the charset to use when
reading a CLOB content with the
ResultSetmethods. Defaults tonull. - clobWriteCharset: Name of the charset to use when
writing a CLOB content with the
PreparedStatementstreaming methods. Defaults to "UTF-8".
Usage of the AceQL JDBC Driver is straightforward:
// Define URL of the path to the AceQL Manager Servlet
// We will use a secure SSL/TLS session. All uploads/downloads of SQL
// commands and data will be encrypted.
String url = "http://localhost:9090/aceql";
// The login info for strong authentication on server side.
// These are *not* the username/password of the remote JDBC Driver,
// but are the auth info checked by remote server
// UserAuthenticator.login(username, password) method.
String database = "sampledb";
String user = "user1";
String password = "password1";
// Register and Load the Driver
DriverManager.registerDriver(new AceQLDriver());
String driverClassName = AceQLDriver.class.getName();
Class.forName(driverClassName);
// Attempts to establish a connection to the remote database:
Properties info = new Properties();
info.put("user", user);
info.put("password", password);
info.put("database", database);
Connection connection = DriverManager.getConnection(url, info);
return connection;
An alternate way of passing connection info is to add them as request
parameters to the URL:
// Define URL of the path to the AceQL Manager Servlet, with all properties
// passed as request parameters.
// (We presume that the aceql_license_key.txt is installed in user.dir.)
String url = "http://localhost:9090/aceql?user=user1&password=password1&database=sampledb";
// Register and Load the Driver
DriverManager.registerDriver(new AceQLDriver());
String driverClassName = AceQLDriver.class.getName();
Class.forName(driverClassName);
// Attempts to establish a connection to the remote database:
Connection connection = DriverManager.getConnection(url, new Properties());
The Connection returned is now ready to be used as a regular or
classic Connection:
String sql = "select * from customer where customer_id >= 1 order by customer_id";
Statement statement = connection.createStatement();
statement.execute(sql);
ResultSet rs = statement.getResultSet();
// Etc.
The built Connection is an instance of AceQLConnection that
contains some specific method. See AceQLConnection for more info.
- Since:
- 6.0
- Author:
- Nicolas de Pomereu
-
Constructor Summary
Constructors Constructor Description AceQLDriver() -
Method Summary
Modifier and Type Method Description booleanacceptsURL(String url)Retrieves whether the driver thinks that it can open a connection to the given URL.Connectionconnect(String url, Properties info)Attempts to make a database connection to the given URL.intgetMajorVersion()Retrieves this driver's major version number.intgetMinorVersion()Gets the driver's minor version number.LoggergetParentLogger()Return the parent Logger of all the Loggers used by this driver.DriverPropertyInfo[]getPropertyInfo(String url, Properties info)Gets information about the possible properties for this driver.booleanjdbcCompliant()Reports whether this driver is a genuine JDBC Compliant ™ driver.
-
Constructor Details
-
AceQLDriver
public AceQLDriver()
-
-
Method Details
-
connect
Attempts to make a database connection to the given URL. The driver will return "null" if it realizes it is the wrong kind of driver to connect to the given URL.acceptsURL(java.lang.String)will return null.The driver will throw
SQLExceptionif it is the right driver to connect to the given URL but has trouble connecting to the database.The
java.util.Propertiesargument can be used to pass arbitrary string tag/value pairs as connection arguments. At least "user", "password" and "database" properties should be included in thePropertiesobject, or either passed through the URL parameter.- Specified by:
connectin interfaceDriver- Parameters:
url- the URL of the database to which to connectinfo- a list of arbitrary string tag/value pairs as connection arguments. At least a "user" and "password" property should be included.- Returns:
- a
Connectionobject that represents a connection to the URL - Throws:
SQLException- if a database access error occurs
-
acceptsURL
Retrieves whether the driver thinks that it can open a connection to the given URL. Typically drivers will returntrueif they understand the subprotocol specified in the URL andfalseif they do not.
The AceQL driver requires an URL which is an http url in the format:
jdbc:aceql:http(s)://<server-name:port>/<AceQL Manager servlet call name>
Example:
jdbc:aceql:https://www.acme.com:9443/aceql
Note that the"jdbc:aceql:"prefix is optional and thus an URL such ashttps://www.aceql.com:9443/aceqlis accepted- Specified by:
acceptsURLin interfaceDriver- Parameters:
url- the URL of the database- Returns:
trueif this driver understands the given URL;falseotherwise- Throws:
SQLException- if a database access error occurs
-
getPropertyInfo
Gets information about the possible properties for this driver.The
getPropertyInfomethod 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 thegetPropertyInfomethod.- Specified by:
getPropertyInfoin interfaceDriver- Parameters:
url- the URL of the database to which to connectinfo- a proposed list of tag/value pairs that will be sent on connect open- Returns:
- an array of
DriverPropertyInfoobjects describing possible properties. - Throws:
SQLException- if a database access error occurs
-
getMajorVersion
public int getMajorVersion()Retrieves this driver's major version number.- Specified by:
getMajorVersionin interfaceDriver- Returns:
- this driver's major version number
-
getMinorVersion
public int getMinorVersion()Gets the driver's minor version number.- Specified by:
getMinorVersionin interfaceDriver- Returns:
- this driver's minor version number
-
jdbcCompliant
public boolean jdbcCompliant()Reports whether this driver is a genuine JDBC Compliant ™ driver. A driver may only reporttruehere if it passes the JDBC compliance tests; otherwise it is required to returnfalse.JDBC compliance requires full support for the JDBC API and full support for SQL 92 Entry Level.
Because the AceQL driver works as a special Driver over HTTP to support many SQL databases vendors, it does not aim to be a genuine JDBC Compliant ™ driver. Thus, method returns
false.- Specified by:
jdbcCompliantin interfaceDriver- Returns:
false
-
getParentLogger
Return the parent Logger of all the Loggers used by this driver. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this driver. Configuring this Logger will affect all of the log messages generated by the driver. In the worst case, this may be the root Logger.- Specified by:
getParentLoggerin interfaceDriver- Returns:
- the parent Logger for this driver
- Throws:
SQLFeatureNotSupportedException- if the driver does not usejava.util.logging.- Since:
- 1.7
-