db
Class DBConnect

java.lang.Object
  extended bydb.DBConnect

public class DBConnect
extends java.lang.Object

DAE Class performs basic functions of connecting to the database and retrieving the results from a user query


Field Summary
private static java.lang.String CONNECTION_STRING
           
 
Constructor Summary
DBConnect()
           
 
Method Summary
static void closeConnection(java.sql.Connection conn)
          Closes the connection object if it is not null
static void closeResults(java.sql.ResultSet rs)
          Closes the results object if it is not null
static void closeResultsStatement(java.sql.ResultSet rs)
          Closes the statement object from the results object if it is not null
static void closeStatement(java.sql.Statement stmt)
          Closes the statement object if it is not null
static jqubeObjects.DataSet conXMLtoDS(java.lang.String xmlString)
          Converts the resultset XML to a generic DataSet object consumed in the GUI
static java.sql.ResultSet executeQuery(java.lang.String query, java.sql.Connection conn)
          Executes a query and returns a resultset object.
static java.lang.String getConnectionString()
          Gets the connection string stored in the static class variable
static java.sql.Connection makeConnection()
          Makes a connection to the DB using the properties file
static java.lang.String makeXML(java.sql.ResultSet rs)
          Converts ResultSet to XML
static int[] processBatchInsert(java.util.ArrayList queryList)
          Processes a batch insert into the database
static java.lang.String processQuery(java.lang.String query)
          Processes the user query and returns the results in XML form suitable for transmission across a network link
static java.lang.String processXMLRequest(java.lang.String xmlString)
          Takes the users XML wrapped query received over the network and passes it along to the database and returns the results set from the sucessful query.
static boolean runNonQuery(java.lang.String query)
          Run a query that does not return any rows
static java.sql.ResultSet runStatQuery(java.lang.String query)
          Runs a query used to get data for statistics calulation purposes
static void setConnectionString(java.lang.String newString)
          Sets the static connection string to the passed in value
static boolean testConnection(java.lang.String connectionString)
          Test the connection string by attempting to establish a connection with the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTION_STRING

private static java.lang.String CONNECTION_STRING
Constructor Detail

DBConnect

public DBConnect()
Method Detail

setConnectionString

public static void setConnectionString(java.lang.String newString)
Sets the static connection string to the passed in value

Parameters:
newString - the new connection string

getConnectionString

public static java.lang.String getConnectionString()
Gets the connection string stored in the static class variable

Returns:
the connection string stored in the class

processXMLRequest

public static java.lang.String processXMLRequest(java.lang.String xmlString)
Takes the users XML wrapped query received over the network and passes it along to the database and returns the results set from the sucessful query.

Parameters:
xmlString - The query wrapped in XML
Returns:
string of results returned from the database

processBatchInsert

public static int[] processBatchInsert(java.util.ArrayList queryList)
Processes a batch insert into the database

Parameters:
queryList - the list of objects to insert into the database
Returns:
return value from the executing batch command

processQuery

public static java.lang.String processQuery(java.lang.String query)
Processes the user query and returns the results in XML form suitable for transmission across a network link

Parameters:
query - XML query to pass to the database
Returns:
XML structured results set containng the results of the query

executeQuery

public static java.sql.ResultSet executeQuery(java.lang.String query,
                                              java.sql.Connection conn)
                                       throws java.sql.SQLException
Executes a query and returns a resultset object.

Parameters:
query - Regular text query (not XML wrapped)
conn - Handle to the database connection
Returns:
The Results Set object containing the results from the query
Throws:
java.sql.SQLException

makeConnection

public static java.sql.Connection makeConnection()
                                          throws java.sql.SQLException,
                                                 java.io.IOException,
                                                 java.lang.Exception
Makes a connection to the DB using the properties file

Returns:
The connection object for the database connection
Throws:
java.sql.SQLException
java.io.IOException
java.lang.Exception

testConnection

public static boolean testConnection(java.lang.String connectionString)
Test the connection string by attempting to establish a connection with the database

Parameters:
connectionString - the string with which to attempt to create the connection
Returns:
true if successful, false otherwise

makeXML

public static java.lang.String makeXML(java.sql.ResultSet rs)
                                throws org.jdom.JDOMException
Converts ResultSet to XML

Parameters:
rs - results set which to convert
Returns:
The XML string of from the results set
Throws:
org.jdom.JDOMException

conXMLtoDS

public static jqubeObjects.DataSet conXMLtoDS(java.lang.String xmlString)
                                       throws java.io.IOException,
                                              org.jdom.JDOMException
Converts the resultset XML to a generic DataSet object consumed in the GUI

Parameters:
xmlString - The XML containing all the values and fields that need to be converted into a DataSet format
Returns:
The DataSet object containing the results
Throws:
java.io.IOException
org.jdom.JDOMException

runStatQuery

public static java.sql.ResultSet runStatQuery(java.lang.String query)
Runs a query used to get data for statistics calulation purposes

Parameters:
query - the query to run against the database
Returns:
the results set object for the query, null if an error occured

runNonQuery

public static boolean runNonQuery(java.lang.String query)
Run a query that does not return any rows

Parameters:
query - the query to run on the database
Returns:
true if the query executed successfully, false otherwise

closeConnection

public static void closeConnection(java.sql.Connection conn)
Closes the connection object if it is not null

Parameters:
conn - connection object to close

closeStatement

public static void closeStatement(java.sql.Statement stmt)
Closes the statement object if it is not null

Parameters:
stmt - statement object to close

closeResults

public static void closeResults(java.sql.ResultSet rs)
Closes the results object if it is not null

Parameters:
rs - results set object to close

closeResultsStatement

public static void closeResultsStatement(java.sql.ResultSet rs)
Closes the statement object from the results object if it is not null

Parameters:
rs - results set for which to close the associated statement object