Added javadoc
This commit is contained in:
parent
f1f101fde3
commit
6ddd2c969b
44 changed files with 382 additions and 71 deletions
|
|
@ -24,17 +24,36 @@ package net.forwardfire.tpquery.store.executor.jdbc;
|
|||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Wrap the SQLException as RuntimeException
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 14, 2015
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SQLExceptionRuntime extends RuntimeException {
|
||||
|
||||
public SQLExceptionRuntime(SQLException parent) {
|
||||
protected SQLExceptionRuntime(SQLException parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the SQLException to an SQLExceptionRuntime
|
||||
* @param e The SQLException to wrap.
|
||||
* @return The new SQLExceptionRuntime.
|
||||
*/
|
||||
public static SQLExceptionRuntime wrap(SQLException e) {
|
||||
return new SQLExceptionRuntime(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps and closes.
|
||||
* note: this is needed because with try-with-resources the compiler produces unreachable bytecode.
|
||||
*
|
||||
* @param closeable The auto closeable to close.
|
||||
* @param e The sql exception to wrap.
|
||||
* @return The new SQLExceptionRuntime.
|
||||
*/
|
||||
public static SQLExceptionRuntime wrapAndClose(AutoCloseable closeable,SQLException e) {
|
||||
return close(closeable,wrap(e));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,18 @@ import net.forwardfire.tpquery.TPQFactory;
|
|||
import net.forwardfire.tpquery.store.executor.AbstractTPQExecutor;
|
||||
import net.forwardfire.tpquery.store.executor.TPQExecutorContext;
|
||||
|
||||
/**
|
||||
* The jdbc query executor.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 14, 2015
|
||||
*/
|
||||
public class TPQExecutorJdbc extends AbstractTPQExecutor<Connection,PreparedStatement> {
|
||||
|
||||
/**
|
||||
* Created the jdbc query executor.
|
||||
* @param context The executor context.
|
||||
*/
|
||||
public TPQExecutorJdbc(TPQExecutorContext context) {
|
||||
super(context);
|
||||
registrateStatementCreator(TPQFactory.StatementLanguage.SQL, (connection,statementText) -> {
|
||||
|
|
@ -45,10 +55,23 @@ public class TPQExecutorJdbc extends AbstractTPQExecutor<Connection,PreparedStat
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Short hand to parameter-less queries.
|
||||
* @param connection The connection to create the prepared statement.
|
||||
* @param queryName The query to execute.
|
||||
* @return The executed prepared statement.
|
||||
*/
|
||||
public PreparedStatement execute(Connection connection,String queryName) {
|
||||
return execute(connection, queryName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes and prepared statement.
|
||||
* @param connection The connection to create the prepared statement.
|
||||
* @param queryName The query to execute.
|
||||
* @param parameters The query parameters.
|
||||
* @return The executed prepared statement.
|
||||
*/
|
||||
public PreparedStatement execute(Connection connection,String queryName,Map<String,Object> parameters) {
|
||||
return execute(createPreparedStatement(connection, queryName, parameters));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue