org.radrails.db.core
Class QueryAdministrator

java.lang.Object
  extended byorg.radrails.db.core.QueryAdministrator

public class QueryAdministrator
extends java.lang.Object

Manages queries and returns objects based on SQL queries. Provides simple methods for getting columns, tables, etc.

Version:
0.3.0
Author:
mbaumbach

Constructor Summary
QueryAdministrator(java.sql.Connection conn)
          Creates a new QueryAdministrator based on the specified connection.
 
Method Summary
 QueryResult execute(java.lang.String sql)
          Executes a SQL query and returns a QueryResult object.
 QueryResult execute(java.lang.String sql, int fetchSize)
          Executes a SQL query and returns a QueryResult object.
 void executeStatement(java.lang.String sql)
          Executes a SQL statement that can modify the table.
 java.util.Collection getColumns(java.lang.String table)
          Gets the columns in a table.
 java.util.Collection getTables()
          Gets the tables in the database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryAdministrator

public QueryAdministrator(java.sql.Connection conn)
Creates a new QueryAdministrator based on the specified connection.

Parameters:
conn - The java.sql.Connection for the database connection.
Method Detail

getTables

public java.util.Collection getTables()
Gets the tables in the database. The tables are a simple Collection of String objects for the names of the tables.

Returns:
A Collection of table names represented as Strings.

getColumns

public java.util.Collection getColumns(java.lang.String table)
Gets the columns in a table. The columns are a simple Collection of String objects for the names of the columns.

Parameters:
table - The table to get the columns for.
Returns:
A Collection of columns names represented as String.

execute

public QueryResult execute(java.lang.String sql,
                           int fetchSize)
                    throws java.sql.SQLException
Executes a SQL query and returns a QueryResult object.

Parameters:
sql - The SQL statement to execute.
fetchSize - The number of rows to fetch.
Returns:
A QueryResult containing the data returned.
Throws:
java.sql.SQLException - If the statement is incorrect syntax or failed to execute.

execute

public QueryResult execute(java.lang.String sql)
                    throws java.sql.SQLException
Executes a SQL query and returns a QueryResult object.

Parameters:
sql - The SQL statement to execute.
Returns:
A QueryResult containing the data returned.
Throws:
java.sql.SQLException - If the statement is incorrect syntax or failed to execute.

executeStatement

public void executeStatement(java.lang.String sql)
                      throws java.sql.SQLException
Executes a SQL statement that can modify the table.

Parameters:
sql - The SQL statement to execute.
Throws:
java.sql.SQLException - If an error occurred during execution.