Sequoia Driver for client side. This driver is a generic driver that is
designed to replace any specific JDBC driver that could be used by a client.
The client only has to know the node where the Sequoia controller is running
and the database he wants to access (the RDBMS could be PostgreSQL, Oracle,
DB2, Sybase, MySQL or whatever, we only need the name of the database and the
Sequoia controller will be responsible for finding the RDBMs hosting this
database).
The Sequoia driver can be loaded from the client with:
Class.forName("org.continuent.sequoia.driver.Driver");
The URL expected for the use with Sequoia is:
jdbc:sequoia://host1:port1,host2:port2/database .
At least one host must be specified. If several hosts are given, one is
picked up randomly from the list. If the currently selected controller fails,
another one is automatically picked up from the list.
Default port number is 25322 if omitted.
Those 2 examples are equivalent:
DriverManager.getConnection("jdbc:sequoia://localhost:/tpcw");
DriverManager.getConnection("jdbc:sequoia://localhost:25322/tpcw");
Examples using 2 controllers for fault tolerance:
DriverManager
.getConnection("jdbc:sequoia://cluster1.continuent.org:25322,cluster2.continuent.org:25322/tpcw");
DriverManager
.getConnection("jdbc:sequoia://localhost:25322,remote.continuent.org:25322/tpcw");
DriverManager
.getConnection("jdbc:sequoia://smpnode.com:25322,smpnode.com:1098/tpcw");
The driver accepts a number of options that starts after a ? sign and are
separated by an & sign. Each option is a name=value pair. Example:
jdbc:sequoia://host/db?option1=value1;option2=value2.
Currently supported options are:
user: user login
password: user password
escapeBackslash: set this to true to escape backslashes when performing escape processing of PreparedStatements
escapeSingleQuote: set this to true to escape single quotes (') when performing escape processing of PreparedStatements
escapeCharacter: use this character to prepend and append to the values when performing escape processing of PreparedStatements
connectionPooling: set this to false if you do not want the driver to perform transparent connection pooling
preferredController: defines the strategy to use to choose a preferred controller to connect to
- jdbc:sequoia://node1,node2,node3/myDB?preferredController=ordered
Always connect to node1, and if not available then try to node2 and
finally if none are available try node3.
- jdbc:sequoia://node1,node2,node3/myDB?preferredController=random
Pickup a controller node randomly (default strategy)
- jdbc:sequoia://node1,node2:25343,node3/myDB?preferredController=node2:25343,node3
Round-robin between node2 and node3, fallback to node1 if none of node2
and node3 is available.
- jdbc:sequoia://node1,node2,node3/myDB?preferredController=roundRobin
Round robin starting with first node in URL.
pingDelayInMs Interval in milliseconds between two pings of a controller. The
default is 1000 (1 second).
controllerTimeoutInMs timeout in milliseconds after which a controller is
considered as dead if it did not respond to pings. Default is 25000 (25
seconds).
persistentConnection: defines if a connection should remain persistent on
cluster backends between connection opening and closing (bypasses any
connection pooling and preserve all information relative to the connection
context. Default is false.
retrieveSQLWarnings: set this to true if you want the controller to retrieve
SQL warnings. Default is false, which means that (Connection|Statement|ResultSet).getWarnings()
will always return null.
allowCommitWithAutoCommit: When set to true, trying to call commit/rollback
on a connection in autoCommit will not throw an exception. If set to false
(default) an SQLException will be thrown when commit is called on a
connection in autoCommit mode.
alwaysGetGeneratedKeys: when set to true, always fetch generated keys even if
not requested with Statement.RETURN_GENERATED_KEYS.
This original code has been inspired from the PostgreSQL JDBC driver by Peter
T. Mount and the MM MySQL JDBC Drivers from Mark Matthews
.
author: Emmanuel Cecchet author: Julie Marguerite author: Mathieu Peltier author: Marek Prochazka author: Nicolas Modrzyk author: Jaco Swart author: Gilles Rayrat version: 1.0 |