cc.glsn.v15
Class SQLConnection

java.lang.Object
  extended by cc.glsn.v15.SQLConnection

public class SQLConnection
extends Object

This class opens an SQL connection and allows you to run queries on it.


Constructor Summary
SQLConnection(ConfigFile C)
          Create an SQLConnection using strings SQLDiver, SQLUrl, SQLUsername and SQLPassword from the given cc.glsn.ConfigFile.
SQLConnection(String Driver, String URL, String Username, String Password)
           
 
Method Summary
 void close()
          Close DB connection.
 void commit()
          Commit changes to DB.
 ResultSet doSingleQuery(String Str)
          Do an SQL query.
 ResultSet doSingleUpdatableQuery(String Str)
          Do an SQL query.
 int doStatement(String Str)
          performs a single SQL statement
 Connection getDBConnection()
           
 boolean ok()
          Determines if the connection is ok
 void reset()
          Reset auto commit to true Close any open statements
 void setAutoCommit(boolean B)
          Sets the value of autocommit.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLConnection

public SQLConnection(ConfigFile C)
              throws SQLException
Create an SQLConnection using strings SQLDiver, SQLUrl, SQLUsername and SQLPassword from the given cc.glsn.ConfigFile.

Parameters:
C - ConfigFile to grab params from
Throws:
SQLException

SQLConnection

public SQLConnection(String Driver,
                     String URL,
                     String Username,
                     String Password)
              throws SQLException
Parameters:
Driver - Class of SQL driver to use. Example: com.mysql.jdbc.Driver
URL - URL to database. Example: jdbc:mysql://host/dbname
Username -
Password -
Throws:
SQLException
Method Detail

reset

public void reset()
           throws SQLException
Reset auto commit to true Close any open statements

Throws:
SQLException

close

public void close()
           throws SQLException
Close DB connection. Also closes any open SQL statements. This will most likely make any ResultSet objects that came from this connection cease to function.

Throws:
SQLException

commit

public void commit()
            throws SQLException
Commit changes to DB. Only needs to be done if autocommit has been set to false.

Throws:
SQLException

setAutoCommit

public void setAutoCommit(boolean B)
                   throws SQLException
Sets the value of autocommit. Default is on.

Parameters:
B -
Throws:
SQLException

ok

public boolean ok()
Determines if the connection is ok

Returns:
true if the sql connection is still connected and seems to work

doStatement

public int doStatement(String Str)
                throws SQLException
performs a single SQL statement

Parameters:
Str - The SQL statement to run
Returns:
the number of rows effected
Throws:
SQLException

doSingleQuery

public ResultSet doSingleQuery(String Str)
                        throws SQLException
Do an SQL query. Note: this ResultSet will not be updatable. It will be read only.

Parameters:
Str - Query
Returns:
A read-only ResultSet created from the query
Throws:
SQLException

doSingleUpdatableQuery

public ResultSet doSingleUpdatableQuery(String Str)
                                 throws SQLException
Do an SQL query. The ResultSet returned will be updatable.

Parameters:
Str - Quert
Returns:
An updatable ResultSet
Throws:
SQLException

getDBConnection

public Connection getDBConnection()