com.adventnet.utilities.db
Class JDBCHandler

java.lang.Object
  |
  +--com.adventnet.utilities.db.JDBCHandler

public class JDBCHandler
extends java.lang.Object


Field Summary
protected  java.sql.Connection connection
           
protected  java.lang.String driverName
           
protected  java.sql.ResultSetMetaData metaData
           
protected  java.lang.String password
           
protected  java.sql.ResultSet resultSet
           
protected  java.util.Vector rows
           
protected  java.sql.Statement statement
           
protected  java.lang.String url
           
protected  java.lang.String userName
           
 
Constructor Summary
JDBCHandler()
           
JDBCHandler(java.lang.String url, java.lang.String drivername, java.lang.String username, java.lang.String password)
           
 
Method Summary
 void close()
          Closes the connection
 void connect()
          Connects with the database.
 void executeQuery(java.lang.String query)
          Used to perform queries such as select (which returns a single ResultSet) on a table.
 void executeQuery(java.lang.String query, java.lang.String[] columnnames)
          Used to perform queries such as select (which returns a single ResultSet) on a table.
 void executeSetQuery(java.lang.String query)
          Used to perform updates, inserts, and deleted on a table.
protected  void finalize()
           
 java.lang.Class getColumnClass(int column)
          Returns the Java Class object of the column type specified by column.
 int getColumnCount()
          Returns the column column of the recently executed select query.
 java.lang.String getColumnName(int column)
          Returns the column name at the specified column.
 java.sql.Connection getConnection()
          Returns the connection with the database.
 java.lang.String getDriverName()
          Get the driverName
 java.lang.String getPassword()
          Get the password
 int getRowCount()
          Returns the row count of the last performed select query.
 java.util.Vector getRows()
          Returns the rows from the ResultSet obtained.
 java.lang.String getSQLString()
          Returns the last sql query performed.
 java.lang.String getUrl()
          Get the url
 java.lang.String getUserName()
          Get the userName
 java.lang.Object getValueAt(int aRow, int aColumn)
          Returns the value at the specified row and column.
static void main(java.lang.String[] args)
           
 void setDriverName(java.lang.String driver)
          Set the driverName
 void setPassword(java.lang.String passwd)
          Set the password
 void setUrl(java.lang.String urlstr)
          Set the url
 void setUserName(java.lang.String user)
          Set the userName
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rows

protected java.util.Vector rows

connection

protected java.sql.Connection connection

statement

protected java.sql.Statement statement

resultSet

protected java.sql.ResultSet resultSet

metaData

protected java.sql.ResultSetMetaData metaData

url

protected java.lang.String url

driverName

protected java.lang.String driverName

userName

protected java.lang.String userName

password

protected java.lang.String password
Constructor Detail

JDBCHandler

public JDBCHandler()

JDBCHandler

public JDBCHandler(java.lang.String url,
                   java.lang.String drivername,
                   java.lang.String username,
                   java.lang.String password)
Method Detail

connect

public void connect()
             throws java.lang.ClassNotFoundException,
                    java.sql.SQLException
Connects with the database.

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.ClassNotFoundException,
                                         java.sql.SQLException
Returns the connection with the database.

getDriverName

public java.lang.String getDriverName()
Get the driverName

setDriverName

public void setDriverName(java.lang.String driver)
Set the driverName

getUrl

public java.lang.String getUrl()
Get the url

setUrl

public void setUrl(java.lang.String urlstr)
Set the url

getUserName

public java.lang.String getUserName()
Get the userName

setUserName

public void setUserName(java.lang.String user)
Set the userName

getPassword

public java.lang.String getPassword()
Get the password

setPassword

public void setPassword(java.lang.String passwd)
Set the password

executeQuery

public void executeQuery(java.lang.String query)
                  throws java.sql.SQLException
Used to perform queries such as select (which returns a single ResultSet) on a table.

executeQuery

public void executeQuery(java.lang.String query,
                         java.lang.String[] columnnames)
                  throws java.sql.SQLException
Used to perform queries such as select (which returns a single ResultSet) on a table. Only the columnNames passed are added in the rows vector

executeSetQuery

public void executeSetQuery(java.lang.String query)
                     throws java.sql.SQLException
Used to perform updates, inserts, and deleted on a table.

getColumnName

public java.lang.String getColumnName(int column)
Returns the column name at the specified column. This has to be executed after executing an query.

getColumnCount

public int getColumnCount()
Returns the column column of the recently executed select query.

getColumnClass

public java.lang.Class getColumnClass(int column)
                               throws java.sql.SQLException
Returns the Java Class object of the column type specified by column.

getRows

public java.util.Vector getRows()
Returns the rows from the ResultSet obtained. This is a Vector of Vectors.

getRowCount

public int getRowCount()
Returns the row count of the last performed select query.

getValueAt

public java.lang.Object getValueAt(int aRow,
                                   int aColumn)
Returns the value at the specified row and column.

getSQLString

public java.lang.String getSQLString()
Returns the last sql query performed.

close

public void close()
           throws java.sql.SQLException
Closes the connection

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception