JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table.data
Class JCResultSetDataSource

java.lang.Object
  |
  +--com.klg.jclass.table.data.AbstractDataSource
        |
        +--com.klg.jclass.table.data.AbstractVectorDataSource
              |
              +--com.klg.jclass.table.data.JCVectorDataSource
                    |
                    +--com.klg.jclass.table.data.JCResultSetDataSource
All Implemented Interfaces:
JCTableDataModel, Serializable, TableDataModel

public class JCResultSetDataSource
extends JCVectorDataSource

This class is a simple read-only JDBC database source that retrieves a result set and stores it internally.

Since:
JClass 4.0K for Java 2. If you are using JClass 4.0J, which is based on JDK 1.1, some of the return types for this class' fields or methods are based on the corresponding com.sun.java.util class.
See Also:
TableDataModel, Serialized Form

Field Summary
protected  int column_count
           
protected  int[] column_type
           
protected  Connection dbcon
           
protected  String query
           
 
Fields inherited from class com.klg.jclass.table.data.JCVectorDataSource
cells, column_labels, columns, is_moving, row_labels, rows
 
Fields inherited from class com.klg.jclass.table.data.AbstractDataSource
listeners
 
Constructor Summary
JCResultSetDataSource()
          Creates a new JCResultSetDataSource object.
JCResultSetDataSource(Connection dbcon, String query)
          Creates new JCResultSetDataSource object given a Connection object and query String.
 
Method Summary
 boolean connect(String driver, String url, Properties properties)
          Establishes a connection to the data source.
 boolean executeQuery()
          Executes the query and stores its results in a JCVector.
 int getColumnDatatype(int column)
          Returns the table datatype for a column.
 int getColumnType(int column)
          Returns the JDBC column type for a column.
 int[] getColumnTypes()
          Returns an array of column types.
 Connection getConnection()
          Returns a JDBC database connection.
 String getQuery()
          Returns the SQL statement.
 void setConnection(Connection dbcon)
          Sets the JDBC database connection.
 void setQuery(String query)
          Sets the SQL statement.
 
Methods inherited from class com.klg.jclass.table.data.JCVectorDataSource
addColumn, addColumn, addRow, addRow, clearCells, deleteColumns, deleteColumns, deleteRows, deleteRows, getCells, getColumnLabels, getLabelValue, getNumColumns, getNumRows, getRowLabels, getTableColumnLabel, getTableDataItem, getTableRowLabel, isCell, isColumnLabel, isLabel, isRowLabel, isValidCell, isValidLabel, moveColumns, moveColumns, moveRows, moveRows, setCell, setCells, setCells, setColumnLabel, setColumnLabels, setColumnLabels, setDataChanged, setLabelValue, setNumColumns, setNumRows, setRowLabel, setRowLabels, setRowLabels
 
Methods inherited from class com.klg.jclass.table.data.AbstractVectorDataSource
createVector, createVector, createVector, createVector, createVector, removeElementsAt, setElementAt, strip
 
Methods inherited from class com.klg.jclass.table.data.AbstractDataSource
addTableDataListener, dispose, fireColumnChanged, fireColumnLabelChanged, fireColumnsAdded, fireColumnsDeleted, fireColumnsMoved, fireDataReset, fireNumColumnsChanged, fireNumRowsChanged, fireRowChanged, fireRowDeleted, fireRowLabelChanged, fireRowsAdded, fireRowsMoved, fireTableDataEvent, fireValueChanged, hasListeners, removeTableDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbcon

protected Connection dbcon

query

protected String query

column_count

protected int column_count

column_type

protected int[] column_type
Constructor Detail

JCResultSetDataSource

public JCResultSetDataSource()
Creates a new JCResultSetDataSource object.


JCResultSetDataSource

public JCResultSetDataSource(Connection dbcon,
                             String query)
Creates new JCResultSetDataSource object given a Connection object and query String.

Parameters:
dbcon -
query -
Method Detail

executeQuery

public boolean executeQuery()
                     throws SQLException
Executes the query and stores its results in a JCVector.

Returns:
Throws:
SQLException - If a database access error occurred.

getConnection

public Connection getConnection()
Returns a JDBC database connection.

Returns:
JDBC database connection

setConnection

public void setConnection(Connection dbcon)
Sets the JDBC database connection.

Parameters:
dbcon -

getQuery

public String getQuery()
Returns the SQL statement.

Returns:
SQL statement

setQuery

public void setQuery(String query)
Sets the SQL statement.

Parameters:
query -

getColumnTypes

public int[] getColumnTypes()
Returns an array of column types.

Returns:
array of column types

getColumnType

public int getColumnType(int column)
Returns the JDBC column type for a column.

Parameters:
column -
Returns:
JDBC column type

getColumnDatatype

public int getColumnDatatype(int column)
Returns the table datatype for a column.

Parameters:
column -
Returns:
table datatype for a column

connect

public boolean connect(String driver,
                       String url,
                       Properties properties)
                throws SQLException
Establishes a connection to the data source.

Parameters:
driver - the class name of the JDBC driver to use to access your database (for example, the JDBC-ODBC driver can be referenced as "com.ms.jdbc.odbc.JdbcOdbcDriver")
Note: A valid driver must be passed in order to connect to a database.
url - a database url of the form jdbc:subprotocol:subname (for example, if you've exposed the JClassDemo using an ODBC driver, a valid URL is "jdbc:odbc:JClassDemo")
properties - a list of arbitrary String tag/value pairs as connection arguments; normally at least a user and password property should be included
Returns:
True if a connection was made successfully; false otherwise
Throws:
SQLException - If a database access error occurred.

Copyright © 2004 Quest Software Inc..
All rights reserved.