com.j256.ormlite.jdbc
Class JdbcDatabaseAccess

java.lang.Object
  extended by com.j256.ormlite.jdbc.JdbcDatabaseAccess
All Implemented Interfaces:
DatabaseAccess

public class JdbcDatabaseAccess
extends Object
implements DatabaseAccess

Implementation of DatabaseAccess interface in JDBC land.

Author:
graywatson

Field Summary
 
Fields inherited from interface com.j256.ormlite.support.DatabaseAccess
MORE_THAN_ONE
 
Constructor Summary
JdbcDatabaseAccess(DataSource dataSource)
          Construct a jdbc template with an associated data source.
 
Method Summary
 PreparedStmt prepareStatement(String sql)
          Generate a prepared statement from a SQL statement.
 long queryForLong(String statement)
          Perform a query whose result should be a single long-integer value.
<T> Object
queryForOne(String statement, Object[] args, int[] argFieldTypeVals, GenericRowMapper<T> rowMapper)
          Perform a SQL query with the associated SQL statement, arguments, and types and returns a single result.
 int update(String statement, Object[] args, int[] argFieldTypeVals)
          Perform a SQL update with the associated SQL statement, arguments, and types.
 int update(String statement, Object[] args, int[] argFieldTypeVals, GeneratedKeyHolder keyHolder)
          Perform a SQL update while returning generated keys with the associated SQL statement, arguments, and types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcDatabaseAccess

public JdbcDatabaseAccess(DataSource dataSource)
Construct a jdbc template with an associated data source.

Method Detail

update

public int update(String statement,
                  Object[] args,
                  int[] argFieldTypeVals)
           throws SQLException
Description copied from interface: DatabaseAccess
Perform a SQL update with the associated SQL statement, arguments, and types.

Specified by:
update in interface DatabaseAccess
Returns:
The number of rows affected by the update.
Throws:
SQLException

update

public int update(String statement,
                  Object[] args,
                  int[] argFieldTypeVals,
                  GeneratedKeyHolder keyHolder)
           throws SQLException
Description copied from interface: DatabaseAccess
Perform a SQL update while returning generated keys with the associated SQL statement, arguments, and types.

Specified by:
update in interface DatabaseAccess
Returns:
The number of rows affected by the update.
Throws:
SQLException

queryForOne

public <T> Object queryForOne(String statement,
                              Object[] args,
                              int[] argFieldTypeVals,
                              GenericRowMapper<T> rowMapper)
                   throws SQLException
Description copied from interface: DatabaseAccess
Perform a SQL query with the associated SQL statement, arguments, and types and returns a single result.

Specified by:
queryForOne in interface DatabaseAccess
Returns:
The first data item returned by the query which can be cast to , null if none, the object DatabaseAccess.MORE_THAN_ONE if more than one result was found.
Throws:
SQLException

queryForLong

public long queryForLong(String statement)
                  throws SQLException
Description copied from interface: DatabaseAccess
Perform a query whose result should be a single long-integer value.

Specified by:
queryForLong in interface DatabaseAccess
Throws:
SQLException

prepareStatement

public PreparedStmt prepareStatement(String sql)
                              throws SQLException
Description copied from interface: DatabaseAccess
Generate a prepared statement from a SQL statement.

Specified by:
prepareStatement in interface DatabaseAccess
Throws:
SQLException


Copyright © 2010. All Rights Reserved.