DLESE Tools
v1.6.0

org.dlese.dpc.services.mmd
Class DbConn

java.lang.Object
  extended by org.dlese.dpc.services.mmd.DbConn

public class DbConn
extends Object

Provides a DB Connection and some low level access methods.


Constructor Summary
DbConn(int bugs, String dbUrl)
           
 
Method Summary
 void closeDb()
           
static String dbstring(double vv)
           
static String dbstring(int vv)
           
static String dbstring(long vv)
           
static String dbstring(String stg)
           
static String dbstring(Timestamp ts)
           
static String dbstringcom(double vv)
           
static String dbstringcom(int vv)
           
static String dbstringcom(long vv)
           
static String dbstringcom(String stg)
           
static String dbstringcom(Timestamp ts)
           
static String dbstringforce(String stg)
           
static String dbstringforcecom(String stg)
           
static String dbstringsub(String stg, boolean forceit)
          Creates a string suitable for MySQL commands, including escaped quotes and the surrounding single quotes.
 String getDbString(String sqlstg)
          Retrieves a single String from the DB.
 Object[][] getDbTable(String sqlstg, String[] types, boolean allownull)
          Retrieves a table from the DB: each array row represents one DB row, and each array column represents a DB column.
 void updateDb(String sqlstg)
          Updates the DB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbConn

public DbConn(int bugs,
              String dbUrl)
       throws MmdException
Throws:
MmdException
Method Detail

closeDb

public void closeDb()
             throws MmdException
Throws:
MmdException

getDbString

public String getDbString(String sqlstg)
                   throws MmdException
Retrieves a single String from the DB.

Parameters:
sqlstg - The SQL string used to query the DB.
Throws:
MmdException

updateDb

public void updateDb(String sqlstg)
              throws MmdException
Updates the DB.

Parameters:
sqlstg - The SQL string to be used.
Throws:
MmdException

getDbTable

public Object[][] getDbTable(String sqlstg,
                             String[] types,
                             boolean allownull)
                      throws MmdException
Retrieves a table from the DB: each array row represents one DB row, and each array column represents a DB column.

Parameters:
sqlstg - The SQL string used to query the DB.
types - An array of the types of the returned columns. Valid values are:
Specified type Returned java type
"boolean" Boolean
"date" Long (milliseconds since 1970)
"double" Double
"int" Integer
"long" Long
"string" String
Throws:
MmdException

dbstringcom

public static String dbstringcom(Timestamp ts)
                          throws MmdException
Throws:
MmdException

dbstring

public static String dbstring(Timestamp ts)
                       throws MmdException
Throws:
MmdException

dbstringcom

public static String dbstringcom(double vv)
                          throws MmdException
Throws:
MmdException

dbstring

public static String dbstring(double vv)
                       throws MmdException
Throws:
MmdException

dbstringcom

public static String dbstringcom(int vv)
                          throws MmdException
Throws:
MmdException

dbstring

public static String dbstring(int vv)
                       throws MmdException
Throws:
MmdException

dbstringcom

public static String dbstringcom(long vv)
                          throws MmdException
Throws:
MmdException

dbstring

public static String dbstring(long vv)
                       throws MmdException
Throws:
MmdException

dbstringcom

public static String dbstringcom(String stg)
                          throws MmdException
Throws:
MmdException

dbstring

public static String dbstring(String stg)
                       throws MmdException
Throws:
MmdException

dbstringforce

public static String dbstringforce(String stg)
                            throws MmdException
Throws:
MmdException

dbstringforcecom

public static String dbstringforcecom(String stg)
                               throws MmdException
Throws:
MmdException

dbstringsub

public static String dbstringsub(String stg,
                                 boolean forceit)
                          throws MmdException
Creates a string suitable for MySQL commands, including escaped quotes and the surrounding single quotes. Throws MmdException if the input string contains an invalid char, unless forceit == true in which case invalid chars are ouput as format "0xabcd".

Throws:
MmdException

DLESE Tools
v1.6.0