|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Handle
Represents a connection to the RDBMS.
Method Summary | |
---|---|
Batch |
batch()
Create a new Batch instance which can be used to queue up and execute statements in a single batch. |
void |
begin()
start a transaction |
void |
clearStatementCache()
Clear this handle's cache of prepared statements. |
void |
close()
Close the connection |
void |
commit()
Commit transaction in progress |
void |
execute(java.lang.String statement)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.util.Collection args)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.util.Map args)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.lang.Object bean)
Execute a statement with named parameters pulling values from a JavaBean |
void |
execute(java.lang.String statement,
java.lang.Object[] args)
Execute an sql statement which does not return any results. |
java.util.Map |
first(java.lang.String statement)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.util.Collection params)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.util.Map args)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.lang.Object bean)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.lang.Object[] params)
Returns the first row matched by the query |
java.sql.Connection |
getConnection()
Obtain the JDBC connection used by this handle |
java.util.Map |
getGlobalParameters()
Obtain a map containing globally set named parameter values. |
void |
inTransaction(TransactionCallback transactionCallback)
Execute transactionCallback in a transaction, cleaning up
as necesary around it |
boolean |
isInTransaction()
Has a transaction been started? |
boolean |
isOpen()
Checks to make sure the connection is live |
void |
load(java.lang.String name)
Eagerly load a named query from the filesystem. |
void |
name(java.lang.String name,
java.lang.String sql)
Prepared a named sql statement |
PreparedBatch |
prepareBatch(java.lang.String statement)
Create a new PreparedBatch instance from arbitrary SQL or a named statement |
java.util.List |
query(java.lang.String query)
Retrieve a collection of map instances from a query. |
java.util.List |
query(java.lang.String statement,
java.util.Collection args)
Execute statement with positional arguments |
java.util.List |
query(java.lang.String statement,
java.util.Map params)
Execute query using name parameters of the form: select id, name from something where id = :something and the
key to the params map is "something" |
void |
query(java.lang.String statement,
java.util.Map args,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
java.util.List |
query(java.lang.String statement,
java.lang.Object bean)
Execute statement with JavaBean mapped named parameter |
java.util.List |
query(java.lang.String statement,
java.lang.Object[] params)
Execute statement with positional arguments |
void |
query(java.lang.String statement,
java.lang.Object[] args,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
void |
query(java.lang.String select,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
void |
rollback()
Rollback a transaction in progress |
void |
script(java.lang.String name)
Find and execute the sql script name . |
int |
update(java.lang.String statement)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.util.Collection args)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.util.Map args)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.lang.Object bean)
Execute an update with named parameters pulling values from a JavaBean |
int |
update(java.lang.String statement,
java.lang.Object[] args)
Execute a statement of the form update foo set bar = foo_id |
Method Detail |
---|
java.sql.Connection getConnection()
void close()
DBIError
- if anything goes really wrong, otherwise just closesvoid execute(java.lang.String statement) throws DBIException
statement
- insert/update/create/delete/call statement
DBIException
void execute(java.lang.String statement, java.lang.Object[] args) throws DBIException
statement
- insert/update/create/delete/call statementargs
- positional arguments to be bound to statement
DBIException
void execute(java.lang.String statement, java.util.Collection args) throws DBIException
statement
- insert/update/create/delete/call statementargs
- positional arguments to be bound to statement
DBIException
void execute(java.lang.String statement, java.util.Map args) throws DBIException
statement
- insert/update/create/delete/call statementargs
- named arguments to be bound to statement
DBIException
void execute(java.lang.String statement, java.lang.Object bean) throws DBIException
statement
- SQL statement with named parametersbean
- JavaBean with properties to be de-referenced for named parameter substitution
DBIException
int update(java.lang.String statement) throws DBIException
update foo set bar = foo_id
statement
- sql statement or named statement
DBIException
- if anything goes wrongint update(java.lang.String statement, java.lang.Object[] args) throws DBIException
update foo set bar = foo_id
statement
- sql statement or named statementargs
- positional args to bind to statement
DBIException
- if anything goes wrongint update(java.lang.String statement, java.util.Collection args) throws DBIException
update foo set bar = foo_id
statement
- sql statement or named statementargs
- positional args to bind to statement
DBIException
- if anything goes wrongint update(java.lang.String statement, java.util.Map args) throws DBIException
update foo set bar = foo_id
statement
- sql statement or named statementargs
- named args to bind to statement
DBIException
- if anything goes wrongint update(java.lang.String statement, java.lang.Object bean) throws DBIException
statement
- sql named statement or direct sqlbean
- JavaBean whose properties
DBIException
java.util.List query(java.lang.String query) throws DBIException
query
- select statement
DBIException
void query(java.lang.String select, RowCallback callback) throws DBIException
select
- sql select statementcallback
- receive callbacks for each row in result
DBIException
void query(java.lang.String statement, java.lang.Object[] args, RowCallback callback) throws DBIException
statement
- sql select statementargs
- position arguments to the statementcallback
- receive callbacks for each row in result
DBIException
void query(java.lang.String statement, java.util.Map args, RowCallback callback) throws DBIException
Named parameters are matched via \s+(:\w+)
outside of quotes,
so basically :id
, :foo_id
, or :id1
type
constructions.
statement
- sql select statementargs
- named arguments to the statementcallback
- receive callbacks for each row in result
DBIException
java.util.List query(java.lang.String statement, java.util.Map params) throws DBIException
select id, name from something where id = :something
and the
key to the params map is "something"
Named parameters are matched via \s+(:\w+)
outside of quotes,
so basically :id
, :foo_id
, or :id1
type
constructions.
statement
- sql statementparams
- map of named parameters
DBIException
java.util.List query(java.lang.String statement, java.lang.Object bean) throws DBIException
statement
- sql or named statement with named paramatersbean
- JavaBean whose properties will be used to populate named parameters
DBIException
java.util.List query(java.lang.String statement, java.lang.Object[] params) throws DBIException
statement
- sql or named statementparams
- positional parameters
DBIException
java.util.List query(java.lang.String statement, java.util.Collection args) throws DBIException
statement
- sql or named statementargs
- positional parameters, bound in iteration order
DBIException
java.util.Map first(java.lang.String statement) throws DBIException
statement
- select statement or named query
DBIException
java.util.Map first(java.lang.String statement, java.lang.Object bean) throws DBIException
statement
- select statement or named querybean
- JavaBean whose properties will be used to populate named parameters
DBIException
java.util.Map first(java.lang.String statement, java.util.Map args) throws DBIException
statement
- select statement or named queryargs
- map of named parameters
DBIException
java.util.Map first(java.lang.String statement, java.lang.Object[] params) throws DBIException
statement
- select statement or named queryparams
- positional parameters
DBIException
java.util.Map first(java.lang.String statement, java.util.Collection params) throws DBIException
statement
- select statement or named queryparams
- positional parameters
DBIException
void begin() throws DBIException
DBIException
void commit() throws DBIException
DBIException
void name(java.lang.String name, java.lang.String sql) throws DBIException
name
- name to issue query undersql
- sql string to use as query
DBIException
- if there is a problem preparing the statementvoid load(java.lang.String name) throws java.io.IOException, DBIException
name
and it will look for a file named [name].sql
in the classpath which
contains a single sql statement.
name
- name of query to load, such as "foo" which will be store din foo.sql
java.io.IOException
DBIException
void inTransaction(TransactionCallback transactionCallback) throws DBIException
transactionCallback
in a transaction, cleaning up
as necesary around it
DBIException
boolean isInTransaction()
boolean isOpen() throws DBIException
DBIException
void script(java.lang.String name) throws DBIException, java.io.IOException
name
. First it will be search for
name.sql
, or, if that is not found, name
will be loaded
directly.
Scripts should seperate statements with a semicolon, for example:
create table wombats (
wombat_id integer primary key,
name varchar(50)
);
insert into wombats (wombat_id, name) values (1, 'Muggie');
call wiggles(1, 2, 3);
name
-
DBIException
java.io.IOException
void rollback() throws DBIException
DBIException
- if the rollback failsvoid clearStatementCache()
Batch batch()
PreparedBatch prepareBatch(java.lang.String statement)
java.util.Map getGlobalParameters()
Handles create a local copy of global parameters specified on the DBI instance used to create the handle. Global parameters added to the Handle will not be added to the DBI instance's globals, however.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |