iglu.jdbc
Class JDBCMisc

java.lang.Object
  |
  +--iglu.jdbc.JDBCMisc

public class JDBCMisc
extends java.lang.Object

A generic class for storing environment-varible-ish data in a database. you give it a token, and it stores a value to it, retrieves a value from it, optionally increments the value. Basically maps tokens to values in a database table.

Version:
1.0
Author:
Travis Bauer, Ryan Scherle

Field Summary
private  java.sql.Connection db
           
private  java.lang.String tblName
           
 
Constructor Summary
JDBCMisc(java.sql.Connection dba, java.lang.String tableName, boolean create)
          Creates and/or connects to a JDBCMisc table.
 
Method Summary
 int addIncrement(java.lang.String kWord)
          Assume that value is an integer, increment it, and return the old value.
 java.lang.String get(java.lang.String kWord)
          Get the value associated with kWord.
 double getDouble(java.lang.String kWord)
          Assumes the value of this keyword is a double, and returns it.
 int getInt(java.lang.String kWord)
          Assumes the value of this keyword is an integer, and returns it.
 int increment(java.lang.String kWord)
          Assume that value is an integer, increment it, and return the old value.
 boolean put(java.lang.String kWord, double value)
          Stores a value in the database.
 boolean put(java.lang.String kWord, int value)
          Stores a value in the database.
 boolean put(java.lang.String kWord, java.lang.String value)
          Stores a value in the database.
 boolean update(java.lang.String kWord, java.lang.String value)
          Replaces existing value with a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

private java.sql.Connection db

tblName

private java.lang.String tblName
Constructor Detail

JDBCMisc

public JDBCMisc(java.sql.Connection dba,
                java.lang.String tableName,
                boolean create)
Creates and/or connects to a JDBCMisc table.

Parameters:
create - Whether the table should be created. If this is false, it is assumed that a table with the proper name already exists in this database.
Method Detail

put

public boolean put(java.lang.String kWord,
                   java.lang.String value)
Stores a value in the database. If the keyword exists, update it to the new value.


put

public boolean put(java.lang.String kWord,
                   int value)
Stores a value in the database. If the keyword exists, update it to the new value.


put

public boolean put(java.lang.String kWord,
                   double value)
Stores a value in the database. If the keyword exists, update it to the new value.


update

public boolean update(java.lang.String kWord,
                      java.lang.String value)
Replaces existing value with a new one. Fails if the key does not exist.


increment

public int increment(java.lang.String kWord)
Assume that value is an integer, increment it, and return the old value. If the value does not exist, do nothing.


get

public java.lang.String get(java.lang.String kWord)
Get the value associated with kWord.


addIncrement

public int addIncrement(java.lang.String kWord)
Assume that value is an integer, increment it, and return the old value. If the value does not exist, set it to 1 (incrementing from 0).


getDouble

public double getDouble(java.lang.String kWord)
Assumes the value of this keyword is a double, and returns it. If the value doesn't exist, returns 0.


getInt

public int getInt(java.lang.String kWord)
Assumes the value of this keyword is an integer, and returns it. If the value doesn't exist, returns 0.