dbpackage
Class DbMethods

java.lang.Object
  extended bydbpackage.DbMethods

public class DbMethods
extends java.lang.Object


Field Summary
static boolean DEBUG
           
 
Constructor Summary
DbMethods()
           
 
Method Summary
 java.sql.ResultSet executeQuery(java.sql.Connection con, java.lang.String sqlStatement)
          This method executes a select statement and returns the result.
 void executeUpdate(java.sql.Connection con, java.lang.String sqlStatement)
          This method executes an update statement
 boolean fieldExists(java.sql.Connection con, java.lang.String tablename, java.lang.String key, java.lang.String colname, java.lang.String sel)
          This method checks to see if a field exists in the database
 java.sql.Connection getConnection(java.lang.String host, java.lang.String database)
          Returns a connection to the MySQL database
 boolean tableExists(java.sql.Connection con, java.lang.String name)
          This method check to see if a table exists in the database
 void testDriver()
          Checks whether the MySQL JDBC Driver is installed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values
Constructor Detail

DbMethods

public DbMethods()
Method Detail

testDriver

public void testDriver()
                throws java.lang.Exception
Checks whether the MySQL JDBC Driver is installed

Throws:
java.lang.Exception

getConnection

public java.sql.Connection getConnection(java.lang.String host,
                                         java.lang.String database)
                                  throws java.lang.Exception
Returns a connection to the MySQL database

Parameters:
host - the name of the host
database - the name of the database
Returns:
Connection the connection to database
Throws:
java.lang.Exception

executeUpdate

public void executeUpdate(java.sql.Connection con,
                          java.lang.String sqlStatement)
                   throws java.lang.Exception
This method executes an update statement

Parameters:
con - database connection
sqlStatement - SQL DDL or DML statement to execute
Returns:
void
Throws:
java.lang.Exception

executeQuery

public java.sql.ResultSet executeQuery(java.sql.Connection con,
                                       java.lang.String sqlStatement)
                                throws java.lang.Exception
This method executes a select statement and returns the result. The RS is not close if it is closed the information is lost

Parameters:
con - database connection
sqlStatement - SQL SELECT statement to execute
Returns:
ResultSet returns result set of query
Throws:
java.lang.Exception

tableExists

public boolean tableExists(java.sql.Connection con,
                           java.lang.String name)
This method check to see if a table exists in the database

Parameters:
con - database connection
name - SQL SELECT statement to execute
Returns:
boolean returns true if it is successful

fieldExists

public boolean fieldExists(java.sql.Connection con,
                           java.lang.String tablename,
                           java.lang.String key,
                           java.lang.String colname,
                           java.lang.String sel)
This method checks to see if a field exists in the database

Parameters:
con - database connection
tablename - the name of the table
key - is the field you are looking for
colname - the column the field is in
sel - what you are looking for
Returns:
ResultSet returns result set of query