public class SQLUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
createJDBCurl(DBStrings dbStrings,
boolean withDBName)
This routine returns the JDBC url corresponding to the DBStrings input.
|
static void |
executeQuery(java.sql.Connection conn,
java.lang.String qry)
Utility method for executing DML
|
static java.sql.Statement |
executeQueryWithResults(java.sql.Connection conn,
java.lang.String qry)
Utility method for executing DML
|
static java.lang.String |
fieldsAsCols(java.util.ArrayList<java.lang.String> fields,
java.lang.String datatype)
Generates DML specifying table columns and their datatypes.
|
static java.util.ArrayList<java.lang.String> |
getAllFields() |
static java.lang.String |
getExceptionMessage(java.lang.Exception ex)
Return a message raised from a SQLException
|
static java.lang.String |
getFieldStr() |
static void |
processQuery(java.lang.Object out,
java.lang.String dml)
Utility method for processing DML with proper output
|
static java.lang.Object |
processQueryWithResults(java.lang.Object out,
java.lang.String query)
Utility method for processing DML with proper output
|
static java.lang.String |
processQueryWithSingleResult(java.sql.Connection conn,
java.lang.String query)
Process a query and returns only the first result of a result set as a
String.
|
static java.sql.ResultSet |
queryAllFromTable(java.sql.Connection conn,
java.lang.String tableName)
return a ResultSet with the result of a "SELECT *" query for a given
table
|
static void |
refreshFields()
loop through entry types to get required, optional, general and utility
fields for this type.
|
static java.util.ArrayList<java.lang.String> |
setFieldRequirement(java.util.ArrayList<java.lang.String> allFields,
java.util.List<java.lang.String> reqFields,
java.util.List<java.lang.String> optFields,
java.util.List<java.lang.String> utiFields,
java.util.ArrayList<java.lang.String> origList) |
public static void refreshFields()
public static java.util.ArrayList<java.lang.String> getAllFields()
public static java.lang.String getFieldStr()
public static java.lang.String fieldsAsCols(java.util.ArrayList<java.lang.String> fields,
java.lang.String datatype)
fields - Contains unique field namesdatatype - Specifies the SQL data type that the fields should take on.public static java.util.ArrayList<java.lang.String> setFieldRequirement(java.util.ArrayList<java.lang.String> allFields,
java.util.List<java.lang.String> reqFields,
java.util.List<java.lang.String> optFields,
java.util.List<java.lang.String> utiFields,
java.util.ArrayList<java.lang.String> origList)
allFields - All existent fields for a given entry typereqFields - list containing required fields for an entry typeoptFields - list containing optional fields for an entry typeutiFields - list containing utility fields for an entry typeorigList - original list with the correct size filled with the default
values for each fieldpublic static java.lang.String getExceptionMessage(java.lang.Exception ex)
ex - The SQLException raisedpublic static java.sql.ResultSet queryAllFromTable(java.sql.Connection conn,
java.lang.String tableName)
throws java.sql.SQLException
conn - Connection to the databasetableName - String containing the name of the table you want to get the
results.java.sql.SQLExceptionpublic static void processQuery(java.lang.Object out,
java.lang.String dml)
throws java.sql.SQLException
out - The output (PrintStream or Connection) object to which the DML
should be sentdml - The DML statements to be processedjava.sql.SQLExceptionpublic static java.lang.Object processQueryWithResults(java.lang.Object out,
java.lang.String query)
throws java.sql.SQLException
out - The output (PrintStream or Connection) object to which the DML
should be sentquery - The DML statements to be processedjava.sql.SQLExceptionpublic static java.lang.String createJDBCurl(DBStrings dbStrings, boolean withDBName)
dbStrings - The DBStrings to use to make the connectionpublic static java.lang.String processQueryWithSingleResult(java.sql.Connection conn,
java.lang.String query)
throws java.sql.SQLException
out - The output (PrintStream or Connection) object to which the DML
should be sentquery - The query statements to be processedjava.sql.SQLExceptionpublic static void executeQuery(java.sql.Connection conn,
java.lang.String qry)
throws java.sql.SQLException
conn - The DML Connection object that will execute the SQLqry - The DML statements to be executedjava.sql.SQLExceptionpublic static java.sql.Statement executeQueryWithResults(java.sql.Connection conn,
java.lang.String qry)
throws java.sql.SQLException
conn - The DML Connection object that will execute the SQLqry - The DML statements to be executedjava.sql.SQLException