rdbms
Class SqlBean

java.lang.Object
  extended by rdbms.SqlBean

public class SqlBean
extends java.lang.Object

This class provides an implementation some of the methods in the java.sql package. This init method creates the connection to the database and retrieves additional database information. The information is retrieved and contained in the class variables for further accessibility.

Version:
1.00
Author:
Douglas Lyon

Constructor Summary
SqlBean()
          Constructor.
 
Method Summary
 void close()
          Closes the connections to this database.
 java.lang.String getCatalogName()
          Gets this Connection's current catalog name.
 int getColumnCount(java.sql.ResultSetMetaData _rsmd)
          Gets the number of columns in a ResultSet.
 java.lang.String[] getColumnTypeNames(java.sql.ResultSetMetaData _rsmd)
          Gets the database types of the columns in a ResultSet.
 java.lang.String getCurrentQuery()
          Gets the value of this current SQL.
 java.sql.DatabaseMetaData getDatabaseMetaData()
          Gets this DataBaseMetaData object.
 java.lang.String getDriverName()
          Gets the name of this JDBC driver.
 java.lang.String getKeyWords()
          Gets the keywords associated with this database.
 java.lang.String[] getNonMSysTables()
          Gets the names of all the Non-System Tables in this Database.
 int getNumberofRows(java.util.Vector v)
          Returns the size of a vector.
 java.lang.String getProductName()
          Gets the name of this database product.
 boolean getReadOnly()
          Gets whether or not this connection to this database is read only.
 java.sql.ResultSet getResultSet()
          Gets the ResultSet contained in this instance variable rs.
 java.sql.ResultSetMetaData getResultSetMetaData(java.sql.ResultSet _rs)
          Gets the MetaData for a specified ResultSet.
 java.lang.String[] getRowAsString(java.sql.ResultSet _rs)
          Converts a row in a ResultSet to a String.
 java.util.Vector getRows(java.sql.ResultSet _rs)
          Converts a ResultSet to a Vector of Strings.
 java.lang.String[] getTableFields(java.sql.ResultSetMetaData _rsmd)
          Gets the names of the columns (fields) in a provided ResultSet.
 java.lang.String getTableName()
          Gets the value of this current table name.
 java.lang.String[] getTableNames()
          Gets the table names contained in this current database.
 java.sql.ResultSet getTableTypes()
          Gets the table types available in this database connection.
 boolean getUsesLocalFiles()
          Gets whether or not this database stores tables in a local file.
 void init()
          Loads specified driver and initializes the Connection to this Database.
static void main(java.lang.String[] args)
          Main entry point for application.
 void modifyDatabase(java.lang.String sql)
          Process an SQL INSERT, DELETE or UPDATE statement string.
 void moveToTop(java.sql.ResultSet _rs)
          Moves to the top of this RecordSet.
 boolean nextRow(java.sql.ResultSet _rs)
          Moves to the next row of a provided ResultSet.
 void print(java.sql.ResultSet _rs)
          Prints the contents of a provided ResultSet.
 void printDataBaseInfo()
          Prints information about this database connection.
 void println(java.lang.Object o)
          Prints the contents of a provided Object.
 void println(java.lang.String[] s)
          Prints the contents of a String array.
 void printResultSetInfo(java.sql.ResultSet _rs)
          Prints information about this current ResultSet.
 java.sql.ResultSet query(java.lang.String sql)
          Creates a Result Set based on an sql query.
 void setDriver(java.lang.String _driver)
          Sets the name of the instance variable, driver, which this class is loadeding.
 void setPassword(java.lang.String _password)
          Sets this classes instance variable, password, for this database connection.
 void setResultSet(java.lang.String myquery)
          Sets this classes resultset instance variable, rs, based on a provided SQL query.
 void setTableName(java.lang.String _tablename)
          Sets this classes instance variable, tablename, for the current database tablename.
 void setUrl(java.lang.String _url)
          Sets this classes instance variable, url, for this database url.
 void setUserId(java.lang.String _userId)
          Sets this classes instance variable, userId, for this database connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlBean

public SqlBean()
Constructor.

Method Detail

getUsesLocalFiles

public boolean getUsesLocalFiles()
Gets whether or not this database stores tables in a local file. * The value is set using the DatabaseMetaData.usesLocalFiles() method * contained in the java.sql package. This method is called and this value is * set in this classes init() method.

Returns:
true if it does, false if not

getReadOnly

public boolean getReadOnly()
Gets whether or not this connection to this database is read only. The value is set using the Connection.isReadOnly() method contained in the java.sql package. This method is called and this value is * set in this classes init() method.

Returns:
true if it is, false if not

getCatalogName

public java.lang.String getCatalogName()
Gets this Connection's current catalog name. * The value is set using the Connection.getCatalog() method * contained in the java.sql package. This method is called and this value is * set in this classes init() method.

Returns:
the current catalog name or null

getDriverName

public java.lang.String getDriverName()
Gets the name of this JDBC driver.

The value is set using the DatabaseMetaData.getDriverName() method * contained in the java.sql package. This method is called and this value is * set in this classes init() method.

Returns:
the JDBC Driver name

getProductName

public java.lang.String getProductName()
Gets the name of this database product. * The value is set using the DatabaseMetaData.getDatabaseProductName() method * contained in the java.sql package. This method is called and this value is * set in this classes init() method.

Returns:
the database product name

getResultSet

public java.sql.ResultSet getResultSet()
Gets the ResultSet contained in this instance variable rs. *

Returns:
this classes ResultSet

getTableName

public java.lang.String getTableName()
Gets the value of this current table name. * The value is set using the SqlBean.setTableName() method *

Returns:
the current table name

getCurrentQuery

public java.lang.String getCurrentQuery()
Gets the value of this current SQL.

The value is set using the SqlBean.query() method

Returns:
the current SQL query

getTableNames

public java.lang.String[] getTableNames()
Gets the table names contained in this current database. The table names are placed in a ResultSet using the DatabaseMetaData.getTables() method. From the ResultSet, the tables are added to a vector and then converted into a String array. This method can be used affineTransform anytime after the init() method is called to set the DataBaseMetaData.

Returns:
the table names

getNonMSysTables

public java.lang.String[] getNonMSysTables()
Gets the names of all the Non-System Tables in this Database. * Retrieves all the tables using the getTableNames() method. Then uses the * getNumberOfMSysTables() to determine the number of SystemTables contained in the * database and places those names in a String array. This method can be used affineTransform anytime * after the init() method is called to set the DataBaseMetaData. *

Returns:
the names of the non-system tables

getTableTypes

public java.sql.ResultSet getTableTypes()
Gets the table types available in this database connection. The results are ordered by table type. * The results are ordered by table type. Typical types are: *
"TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL", "TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". *

Returns:
the current SQL query

setResultSet

public void setResultSet(java.lang.String myquery)
Sets this classes resultset instance variable, rs, based on a provided SQL query. *

Parameters:
myquery - the SQL query

setUserId

public void setUserId(java.lang.String _userId)
Sets this classes instance variable, userId, for this database connection. * This is the database user on whose behalf the Connection is being made for *

Parameters:
_userId - the database UserId

setPassword

public void setPassword(java.lang.String _password)
Sets this classes instance variable, password, for this database connection. * The password associated with the database user on whose behalf the * Connection is being made for.

Parameters:
_password - the database Password

setUrl

public void setUrl(java.lang.String _url)
Sets this classes instance variable, url, for this database url. * The url is in the form of jdbc:subprotocol:subname *

Parameters:
_url - the database url

setDriver

public void setDriver(java.lang.String _driver)
Sets the name of the instance variable, driver, which this class is loadeding. * This is the string representation of the driver being loaded to make the connection to the database. *

Parameters:
_driver - the driver name

setTableName

public void setTableName(java.lang.String _tablename)
Sets this classes instance variable, tablename, for the current database tablename. *

Parameters:
_tablename - the database tablename

init

public void init()
Loads specified driver and initializes the Connection to this Database. *

Loads the driver and Connects to the Database *
Retrieves and sets Database/Connection Information as follows: *
    MetaData of this Database *
    Read Only Property *
    Uses Local Files Property *
    Driver Name Used for the Connection *
    Database Product Name *
    Table Types in this Database


printDataBaseInfo

public void printDataBaseInfo()
Prints information about this database connection. *


Prints the following information:
    The name of this database product *
    This Connection's current catalog name *
    Is this connection in read-only mode *
    Does this database store tables in a local files *
    The name of this JDBC driver *
    The SQL keywords of this database *
    The table types of all the tables in this database *
    The names of all the tables in this database *
    The names of all the non-system tables in this database


printResultSetInfo

public void printResultSetInfo(java.sql.ResultSet _rs)
Prints information about this current ResultSet.


Prints the following information:
    The column names (fields) of this database *
    The type name of the columns (fields) used by this database

Parameters:
_rs - the current ResultSet

close

public void close()
Closes the connections to this database.


query

public java.sql.ResultSet query(java.lang.String sql)
Creates a Result Set based on an sql query. *

Parameters:
sql - the sql query
Returns:
the ResultSet

getResultSetMetaData

public java.sql.ResultSetMetaData getResultSetMetaData(java.sql.ResultSet _rs)
Gets the MetaData for a specified ResultSet. *

Parameters:
_rs - the ResultSet
Returns:
the ResultSetMetaData

getColumnCount

public int getColumnCount(java.sql.ResultSetMetaData _rsmd)
Gets the number of columns in a ResultSet. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
number of Columns (fields)

getKeyWords

public java.lang.String getKeyWords()
Gets the keywords associated with this database. *

Returns:
the keywords

getColumnTypeNames

public java.lang.String[] getColumnTypeNames(java.sql.ResultSetMetaData _rsmd)
Gets the database types of the columns in a ResultSet. * These are the type name used by this database. If the column type is a user-defined type, * then a fully-qualified type name is returned. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
the column types

getRowAsString

public java.lang.String[] getRowAsString(java.sql.ResultSet _rs)
Converts a row in a ResultSet to a String. *

Parameters:
_rs - the ResultSet pointed to a particular row * @return the contents of the ResultSet

getRows

public java.util.Vector getRows(java.sql.ResultSet _rs)
Converts a ResultSet to a Vector of Strings. *

Parameters:
_rs - the ResultSet
Returns:
the vector containing the ResultSet with each row as a String

getNumberofRows

public int getNumberofRows(java.util.Vector v)
Returns the size of a vector. Used with the getRows() method that converts a ResultSet to a vector. *

Parameters:
v - the Vector
Returns:
the number of rows

moveToTop

public void moveToTop(java.sql.ResultSet _rs)
Moves to the top of this RecordSet.

Parameters:
_rs - the ResultSet

print

public void print(java.sql.ResultSet _rs)
Prints the contents of a provided ResultSet.

Parameters:
_rs - the ResultSet

println

public void println(java.lang.Object o)
Prints the contents of a provided Object. * Uses the toString() method for the provided object.

Parameters:
o - the Object

println

public void println(java.lang.String[] s)
Prints the contents of a String array.

Parameters:
s - an array of string to be printed

nextRow

public boolean nextRow(java.sql.ResultSet _rs)
Moves to the next row of a provided ResultSet. *

Parameters:
_rs - the ResultSet

getTableFields

public java.lang.String[] getTableFields(java.sql.ResultSetMetaData _rsmd)
Gets the names of the columns (fields) in a provided ResultSet. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
the table names

getDatabaseMetaData

public java.sql.DatabaseMetaData getDatabaseMetaData()
Gets this DataBaseMetaData object.

Returns:
this DataBaseMetaData

modifyDatabase

public void modifyDatabase(java.lang.String sql)
Process an SQL INSERT, DELETE or UPDATE statement string. * Additionally, this could be an SQL statement that returns nothing such as SQL DDL statments. *

Parameters:
sql - the SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing

main

public static void main(java.lang.String[] args)
Main entry point for application.

Parameters:
args - the command line arguments