| com.noelios.restlet.ClientHelper com.noelios.restlet.ext.jdbc.JdbcClientHelper
JdbcClientHelper | public class JdbcClientHelper extends ClientHelper (Code) | | Client connector to a JDBC database. To send a request to the server,
create a new instance of a client supporting the JDBC Protocol and invoke the
handle() method. Alternatively, you can create a new Call 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.
Do not forget to register
your JDBC drivers before using this client. See
JDBC DriverManager API for details
Sample XML request:
true
scott
tiger
1234
true
true
UPDATE myTable SET myField1="value1"
SELECT msField1, myField2 FROM myTable
Several SQL
Statements can be specified. A RowSetRepresentation of the last
correctly executed SQL request is returned to the Client.
See Also: com.noelios.restlet.ext.jdbc.RowSetRepresentation author: Jerome Louvel (contact@noelios.com) author: Thierry Boileau |
Method Summary | |
public static Request | create(String jdbcURI, Representation request) Creates an uniform call. | protected static ObjectPool | createConnectionPool(String uri, Properties properties) Creates a connection pool for a given connection configuration.
Parameters: uri - The connection URI. Parameters: properties - The connection properties. | protected Connection | getConnection(String uri, Properties properties, boolean usePooling) Returns a JDBC connection.
Parameters: uri - The connection URI. Parameters: properties - The connection properties. Parameters: usePooling - Indicates if the connection pooling should be used. | public void | handle(Request request, Response response) Handles a call. | public static String | sqlEncode(String query) Escapes quotes in a SQL query.
Parameters: query - The SQL query to escape. |
JdbcClientHelper | public JdbcClientHelper(Client client)(Code) | | Constructor.
Parameters: client - The client to help. |
create | public static Request create(String jdbcURI, Representation request)(Code) | | Creates an uniform call.
Parameters: jdbcURI - The database's JDBC URI (ex:jdbc:mysql://[hostname]/[database]). Parameters: request - The request to send (valid XML request). |
createConnectionPool | protected static ObjectPool createConnectionPool(String uri, Properties properties)(Code) | | Creates a connection pool for a given connection configuration.
Parameters: uri - The connection URI. Parameters: properties - The connection properties. The new connection pool. |
getConnection | protected Connection getConnection(String uri, Properties properties, boolean usePooling) throws SQLException(Code) | | Returns a JDBC connection.
Parameters: uri - The connection URI. Parameters: properties - The connection properties. Parameters: usePooling - Indicates if the connection pooling should be used. The JDBC connection. throws: SQLException - |
handle | public void handle(Request request, Response response)(Code) | | Handles a call.
Parameters: request - The request to handle. Parameters: response - The response to update. |
sqlEncode | public static String sqlEncode(String query)(Code) | | Escapes quotes in a SQL query.
Parameters: query - The SQL query to escape. The escaped SQL query. |
|
|