@Deprecated public class JdbcClientHelper extends ClientHelper
Request
with the
JDBC URI as the resource reference and use an XML request as the entity.
Database connections are optionally pooled using Apache Commons DBCP. In this case, a different connection pool is created for each unique combination of JDBC URI and connection properties.
Paging is supported via two header elements: "start" for the index of the first result (0 by default) and "limit" for the maximum number of results retrieved (unlimited by default).
Do not forget to register your JDBC drivers before using this client. See
DriverManager
for details.
Sample XML request:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<request>
<header>
<connection>
<usePooling>true</usePooling>
<property
name="user">scott</property >
<property
name="password">tiger</property >
<property
name="...">1234</property >
<property
name="...">true</property >
</connection>
<start>10</start>
<limit>20</limit>
<returnGeneratedKeys>true</returnGeneratedKeys>
</header>
<body>
<statement>UPDATE myTable SET
myField1="value1" </statement>
<statement>SELECT msField1, myField2 FROM
myTable</statement>
</body>
</request>
Several SQL Statements can be specified. A RowSetRepresentation
of
the last correctly executed SQL request is returned to the Client.
RowSetRepresentation
Constructor and Description |
---|
JdbcClientHelper(Client client)
Deprecated.
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static Request |
create(String jdbcURI,
Representation request)
Deprecated.
Creates an uniform call.
|
static org.apache.commons.pool.ObjectPool |
createConnectionPool(String uri,
Properties properties)
Deprecated.
Creates a connection pool for a given connection configuration.
|
protected Connection |
getConnection(String uri,
Properties properties,
boolean usePooling)
Deprecated.
Returns a JDBC connection.
|
void |
handle(Request request,
Response response)
Deprecated.
Handles a call.
|
static String |
sqlEncode(String query)
Deprecated.
Escapes quotes in a SQL query.
|
getConnectorService, getContext, getProtocols, start, stop, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
public JdbcClientHelper(Client client)
client
- The client to help.public static Request create(String jdbcURI, Representation request)
jdbcURI
- The database's JDBC URI (ex:
jdbc:mysql://[hostname]/[database]).request
- The request to send (valid XML request).public static org.apache.commons.pool.ObjectPool createConnectionPool(String uri, Properties properties)
uri
- The connection URI.properties
- The connection properties.public static String sqlEncode(String query)
query
- The SQL query to escape.protected Connection getConnection(String uri, Properties properties, boolean usePooling) throws SQLException
uri
- The connection URI.properties
- The connection properties.usePooling
- Indicates if the connection pooling should be used.SQLException
public void handle(Request request, Response response)
handle
in class RestletHelper<Client>
request
- The request to handle.response
- The response to update.Copyright © 2005–2015. All rights reserved.