|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.skife.jdbi.DBI
Entry point for operations. May act as a configured bean, or provide handles via static functions.
Constructor Summary | |
DBI()
Attempt to auto-configure a DBi instance |
|
DBI(ConnectionFactory factory)
Use a custom implementation of ConnectionFactory to obtain
JDBC connections for handles created by this DBI |
|
DBI(javax.sql.DataSource source)
Obtain a new DBI instance |
|
DBI(javax.sql.DataSource source,
java.lang.String name,
java.lang.String pass)
Obtain a new DBI instance |
|
DBI(java.lang.String wombat)
If wombat begins "jdbc:" the string will be treated as a jdbc driver
otherwise it will be used as the key for a jndi lookup to findInternal a DataSrouce . |
|
DBI(java.lang.String wombat,
java.lang.String name,
java.lang.String pass)
If wombat begins "jdbc:" the string will be treated as a jdbc driver
otherwise it will be used as the key for a jndi lookup to findInternal a DataSrouce . |
Method Summary | |
java.util.Map |
getNamedStatements()
Obtain an unmodifiable map of all the named statements known to this DBI instance. |
void |
load(java.lang.String name)
Eagerly load a named query from the filesystem. |
void |
name(java.lang.String name,
java.lang.String statement)
Prepared a named sql statement |
Handle |
open()
Obtain a new Handle instance |
static Handle |
open(javax.sql.DataSource source)
|
static void |
open(javax.sql.DataSource source,
HandleCallback callback)
Execute callback with an opened handle, closing the handle, and cleaning
up resources when the callback finishes. |
static Handle |
open(javax.sql.DataSource source,
java.lang.String name,
java.lang.String pass)
Obtain a handle directly from a datasource |
static void |
open(javax.sql.DataSource source,
java.lang.String name,
java.lang.String pass,
HandleCallback callback)
Execute callback with an opened handle, closing the handle, and cleaning
up resources when the callback finishes. |
void |
open(HandleCallback callback)
Execute the callback with an open handle, closing, and cleaning up resources, after the callback exits or excepts |
static Handle |
open(java.lang.String connString)
Obtain a handle directly from a datasource |
static void |
open(java.lang.String connString,
HandleCallback callback)
Execute callback with an opened handle, closing the handle, and cleaning
up resources when the callback finishes. |
static Handle |
open(java.lang.String wombat,
java.lang.String name,
java.lang.String pass)
Obtain a handle directly from a datasource |
static void |
open(java.lang.String wombat,
java.lang.String name,
java.lang.String pass,
HandleCallback callback)
Execute callback with an opened handle, closing the handle, and cleaning
up resources when the callback finishes. |
void |
setHandleDecoratorBuilder(HandleDecoratorBuilder builder)
Specify a decorator builder to decorate all handles created by this DBI instance |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DBI() throws java.io.IOException
It first looks for an org.skife.jdbi.properties-file
system property which
represents a properties file to be loaded via the classpath. If that is not found, it looks
for jdbi.properties
, then jdbc.properties
, then
dbi.properties
, then finally database.properties
on the classpath.
It will use the first it finds and stop looking for others once it finds one.
|
JDBC Connection URL, ie jdbc:derby:my_database ,
required
|
|
JDBC Driver class name, ie org.apache.derby.jdbc.EmbeddedDriver ,
required
|
|
Username to be used when obtaining connections from the database, optional |
|
Password to be used when obtaining connections from the database, optional |
|
Unstable Feature class name of a HandleDecoratorBuilder
to be used to decorate Handle instances obtained from the
DBI instance instantiated. This feature is functionally stable,
but the specific api may change somewhat while it remains offically unstable.
Please read the notes regarding the org.skife.jdbi.unstable package
before using this. Optional.
|
java.io.IOException
- on error loading jdbi.properties
DBIError
- if the properties file exists but is invalidpublic DBI(java.lang.String wombat)
wombat
begins "jdbc:" the string will be treated as a jdbc driver
otherwise it will be used as the key for a jndi lookup to findInternal a DataSrouce
.
If neither works, will throw a DBIError
wombat
- jdbc connection string or jndi lookup
DBIError
- if anything untoward happens.public DBI(java.lang.String wombat, java.lang.String name, java.lang.String pass)
wombat
begins "jdbc:" the string will be treated as a jdbc driver
otherwise it will be used as the key for a jndi lookup to findInternal a DataSrouce
.
If neither works, will throw a DBIError
wombat
- jdbc connection string or jndi lookupname
- username for grabbing connectionspass
- password for grabbing connections
DBIError
- if anything untoward happens.public DBI(javax.sql.DataSource source)
source
- DataSource provided by clientpublic DBI(javax.sql.DataSource source, java.lang.String name, java.lang.String pass)
source
- DataSource provided by clientname
- jdbc usernamepass
- jdbc user passwordpublic DBI(ConnectionFactory factory)
ConnectionFactory
to obtain
JDBC connections for handles created by this DBI
Method Detail |
public Handle open() throws DBIException
open
in interface IDBI
DBIException
public void open(HandleCallback callback) throws DBIException
open
in interface IDBI
DBIException
- if exception is thrown from the callback, or
an exception occurs with the database
DBIError
- if an Error is thrown from the callbackpublic java.util.Map getNamedStatements()
getNamedStatements
in interface IDBI
public void name(java.lang.String name, java.lang.String statement) throws DBIException
name
in interface IDBI
name
- name to issue query understatement
- sql string to use as query
DBIException
- if there is a problem preparing the statementpublic void load(java.lang.String name) throws DBIException, java.io.IOException
name
and it will look for a file named [name].sql
in the classpath which
contains a single sql statement.
load
in interface IDBI
name
- name of query to load, such as "foo" which will be store din foo.sql
java.io.IOException
DBIException
public void setHandleDecoratorBuilder(HandleDecoratorBuilder builder)
public static Handle open(java.lang.String connString) throws DBIException
DBIException
public static Handle open(java.lang.String wombat, java.lang.String name, java.lang.String pass) throws DBIException
DBIException
public static Handle open(javax.sql.DataSource source) throws DBIException
DBIException
public static Handle open(javax.sql.DataSource source, java.lang.String name, java.lang.String pass) throws DBIException
DBIException
public static void open(java.lang.String connString, HandleCallback callback) throws DBIException
callback
with an opened handle, closing the handle, and cleaning
up resources when the callback finishes.
DBIException
public static void open(java.lang.String wombat, java.lang.String name, java.lang.String pass, HandleCallback callback) throws DBIException
callback
with an opened handle, closing the handle, and cleaning
up resources when the callback finishes.
DBIException
public static void open(javax.sql.DataSource source, HandleCallback callback) throws DBIException
callback
with an opened handle, closing the handle, and cleaning
up resources when the callback finishes.
DBIException
public static void open(javax.sql.DataSource source, java.lang.String name, java.lang.String pass, HandleCallback callback) throws DBIException
callback
with an opened handle, closing the handle, and cleaning
up resources when the callback finishes.
DBIException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |