com.jalios.util
Class SQLQueryResult

java.lang.Object
  extended by com.jalios.util.SQLQueryResult

public class SQLQueryResult
extends Object

This class performs a SQL (SELECT) query and provides access to the result set.

Since:
jcms-5.5.0
Version:
$Revision: 19868 $
Author:
Olivier Dedieu

Nested Class Summary
 class SQLQueryResult.Row
          This class represents a row.
 
Field Summary
protected  String[] columnNames
           
protected  int errorCode
           
protected  String errorMessage
           
protected  boolean isError
           
static String REVISION
           
protected  List rowList
           
protected  String sqlQuery
           
protected  String sqlState
           
 
Constructor Summary
SQLQueryResult(Connection conn, String sqlQuery, Object[] params, int maxRows)
          Constructs a new SQLQueryResult.
SQLQueryResult(ResultSet rs)
          Constructs a new SQLQueryResult.
SQLQueryResult(String dataSource, String sqlQuery, int maxRows)
          Constructs a new SQLQueryResult.
SQLQueryResult(String dataSource, String sqlQuery, Object[] params, int maxRows)
          Constructs a new SQLQueryResult.
SQLQueryResult(String dataSource, String select, String from, String orderby, String[] whereParams, String[] whereValues, boolean and, int maxRows)
          Constructs a new SQLQueryResult.
 
Method Summary
 int getColumnCount()
          Returns the column count
 String[] getColumnNames()
          Returns the column names
 int getErrorCode()
          Returns the error code
 String getErrorMessage()
          Returns the error message
 int getRowCount()
          Returns the count of rows.
 List getRowList()
          Returns the list of rows.
 String getSQLQuery()
          Returns the error sqlQuery
 String getSQLState()
          Returns the SQL state
 boolean isEmpty()
          Returns true if no result
 boolean isError()
          Returns true if an error occured during the query process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

columnNames

protected String[] columnNames

rowList

protected List rowList

isError

protected boolean isError

errorMessage

protected String errorMessage

errorCode

protected int errorCode

sqlState

protected String sqlState

sqlQuery

protected String sqlQuery
Constructor Detail

SQLQueryResult

public SQLQueryResult(String dataSource,
                      String select,
                      String from,
                      String orderby,
                      String[] whereParams,
                      String[] whereValues,
                      boolean and,
                      int maxRows)
Constructs a new SQLQueryResult. Build a SELECT query from given parameters.

Parameters:
dataSource - the name of the data source (eg. "jdbc/TestDB")
select - the table filed to select or *
from - the table name to work with.
orderby - the order by parameter
whereParams - an array of parameters
whereValues - an array of parameters value
and - should be 'AND' or 'OR' between parameters
maxRows - the max rows limit; zero means there is no limit

SQLQueryResult

public SQLQueryResult(String dataSource,
                      String sqlQuery,
                      int maxRows)
Constructs a new SQLQueryResult.

Parameters:
dataSource - the name of the data source (eg. "jdbc/TestDB")
sqlQuery - the SQL (SELECT) query
maxRows - the max rows limit; zero means there is no limit
Since:
jcms-5.5.0

SQLQueryResult

public SQLQueryResult(String dataSource,
                      String sqlQuery,
                      Object[] params,
                      int maxRows)
Constructs a new SQLQueryResult.

Parameters:
dataSource - the name of the data source (eg. "jdbc/TestDB")
sqlQuery - the SQL query (may be a parametrized SQL query)
params - the query parameters
maxRows - the max rows limit; zero means there is no limit
Since:
jcms-5.5.0

SQLQueryResult

public SQLQueryResult(Connection conn,
                      String sqlQuery,
                      Object[] params,
                      int maxRows)
Constructs a new SQLQueryResult.

Parameters:
conn - the JDBC connection
sqlQuery - the SQL query (may be a parametrized SQL query)
params - the query parameters
maxRows - the max rows limit; zero means there is no limit
Since:
jcms-5.5.0

SQLQueryResult

public SQLQueryResult(ResultSet rs)
Constructs a new SQLQueryResult.

Parameters:
rs - a JDBC ResultSet
Since:
jcms-5.5.0
Method Detail

getColumnNames

public String[] getColumnNames()
Returns the column names

Returns:
the column names
Since:
jcms-5.5.0

getColumnCount

public int getColumnCount()
Returns the column count

Returns:
the column count
Since:
jcms-5.5.0

isEmpty

public boolean isEmpty()
Returns true if no result

Returns:
true if no result
Since:
jcms-5.5.0

getRowList

public List getRowList()
Returns the list of rows. Each row is represented by a SQLQueryResult.Row object.

Returns:
the list of rows.
Since:
jcms-5.5.0

getRowCount

public int getRowCount()
Returns the count of rows.

Returns:
the count of rows.
Since:
jcms-5.5.0

isError

public boolean isError()
Returns true if an error occured during the query process

Returns:
true if an error occured during the query process.
Since:
jcms-5.5.0

getErrorCode

public int getErrorCode()
Returns the error code

Returns:
the error code.
Since:
jcms-5.5.0
See Also:
SQLException.getErrorCode()

getSQLQuery

public String getSQLQuery()
Returns the error sqlQuery

Returns:
the error sqlQuery.
Since:
jcms-5.5.0

getErrorMessage

public String getErrorMessage()
Returns the error message

Returns:
the error message.
Since:
jcms-5.5.0

getSQLState

public String getSQLState()
Returns the SQL state

Returns:
the SQL state.
Since:
jcms-5.5.0
See Also:
SQLException.getSQLState()


Copyright © 2001-2010 Jalios SA. All Rights Reserved.