uk.ac.ed.inf.utils.database
Class DbWriter

java.lang.Object
  extended by uk.ac.ed.inf.utils.database.DbManaged
      extended by uk.ac.ed.inf.utils.database.DbWriter

public class DbWriter
extends DbManaged

To write to a database table

Version:
20 Feb 2009
Author:
Luna De Ferrari luna.deferrari-at-ed.ac.uk

Constructor Summary
DbWriter(DbManager dbManager)
           
 
Method Summary
 java.sql.ResultSet executeQuery(java.lang.String sqlQuery)
          Executes any SQL update which returns some results.
 java.lang.Integer executeQueryReturn1Id(java.lang.String sqlInsertInto)
          Executes an SQL update (an individual row insert) and returns the auto-generated key (identifier) of the first inserted row.
 java.sql.ResultSet executeQueryReturnIds(java.lang.String sqlInsertInto)
          Executes an SQL update (usually a row insert) which returns the identifier(s) of the inserted rows.
 boolean executeUpdate(java.lang.String sqlToExecute)
          Executes any SQL update which does not return results (create/drop table etc)
 TableWriter getTableWriter(java.lang.String table)
          Object to write to a table
 
Methods inherited from class uk.ac.ed.inf.utils.database.DbManaged
getDbConnection, getDbManager
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbWriter

public DbWriter(DbManager dbManager)
Method Detail

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sqlQuery)
Executes any SQL update which returns some results.

Parameters:
sqlQuery - sql code to execute
Returns:
the results

executeQueryReturn1Id

public java.lang.Integer executeQueryReturn1Id(java.lang.String sqlInsertInto)
Executes an SQL update (an individual row insert) and returns the auto-generated key (identifier) of the first inserted row.

Parameters:
sqlInsertInto - sql code to execute
Returns:
the auto-generated key of the first inserted row

executeQueryReturnIds

public java.sql.ResultSet executeQueryReturnIds(java.lang.String sqlInsertInto)
Executes an SQL update (usually a row insert) which returns the identifier(s) of the inserted rows.

Parameters:
sqlInsertInto - sql code to execute
Returns:
the identifiers of the inserted rows

executeUpdate

public boolean executeUpdate(java.lang.String sqlToExecute)
Executes any SQL update which does not return results (create/drop table etc)

Parameters:
sqlToExecute - sql code to execute
Returns:
true if the sql command was executed

getTableWriter

public TableWriter getTableWriter(java.lang.String table)
Object to write to a table