public class DBSQL
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DBSQL.JavaToSqlType |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NUM_ROWS
Attribute name for the number of rows returned from a query
|
static java.lang.String |
ROOT
Name of root element for a query result
|
| Constructor and Description |
|---|
DBSQL() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
batch(java.sql.Connection dbConnection,
java.lang.String[] batch)
Executes a batch of commands
|
static java.lang.String |
clobToString(java.sql.Clob clob)
Converts an Oracle clob to a string.
|
static java.lang.String |
escCharacters(java.lang.String input)
This will escape all non-database friendly characters by appendiing the escape character
"\" before them.
|
static int |
insert(java.sql.Connection dbConnection,
java.lang.String sql)
insert to database
|
static int |
insert(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
Insert to database
|
static int |
insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql)
Insert to database using JDBC 3.0 which will return the key of the new
row.
|
static int |
insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
Insert to database using JDBC 3.0 which will return the key of the new
row.
|
static int |
insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params,
ISqlTable sqlTable)
Insert to database using JDBC 3.0 which will return the key of the new
row.
|
boolean |
isIncludeIndex() |
java.lang.String |
query(java.sql.Connection connection,
java.lang.String sql)
Retrieve a query from the db.
|
java.lang.String |
query(java.sql.ResultSet rs)
Retrieve a query from the db.
|
XMLObject |
query2XMLObject(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName,
java.lang.String[] elementNames,
java.lang.String dateFormat,
java.util.List<SqlField> params)
This will get all the rows from the ResultSet and store these into an
xmlObject.
|
XMLObject |
query2XMLObject(java.sql.ResultSet rs,
java.lang.String rootName,
java.lang.String[] elementNames,
java.lang.String dateFormat)
This will get all the rows from the ResultSet and store these into an xmlObject.
|
static java.lang.String |
queryOne(java.sql.Connection connection,
java.lang.String sql,
java.util.List<SqlField> params)
this gets the result of a count or max etc
|
static java.lang.String |
queryOne(java.sql.ResultSet rs)
this gets the result of a count or max etc
|
java.lang.String |
queryXML(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName)
Retrieve a query from the db.
|
java.lang.String |
queryXML(java.sql.ResultSet rs,
java.lang.String rootName) |
java.lang.String |
queryXMLLong(java.sql.ResultSet rs,
java.lang.String[] elementNames,
java.lang.String rootName,
java.lang.String dateFormat)
builds the result set as <elementName>resultset.value</elementName>
|
java.lang.String |
queryXMLShort(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName)
Sends a query to the database and maps the resultset to an xml string.
|
java.lang.String |
queryXMLShort(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName,
java.util.List<SqlField> params)
Sends a query to the database and maps the resultset to an xml string.
|
java.lang.String |
queryXMLShort(java.sql.ResultSet rs,
java.lang.String rootName)
builds the result set as <row index="x" attribute=value ...> where
attribute name is the name of the table column.
|
java.lang.String |
queryXMLShort(java.sql.ResultSet rs,
java.lang.String[] elementNames,
java.lang.String rootName,
java.lang.String dateFormat)
builds the result set as <row index="x" attribute=value ...> where attribute name is the name of the table
column.
|
java.lang.String |
queryXMLShort(java.sql.ResultSet rs,
java.lang.String rootName,
java.lang.String dateFormat)
builds the result set as <row index="x" attribute=value ...> where
attribute name is the name of the table column.
|
void |
setIncludeIndex(boolean includeIndex) |
static int |
update(java.sql.Connection connection,
java.lang.String sql)
update to database
|
static int |
update(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
Update to database.
|
public static final java.lang.String ROOT
public static final java.lang.String NUM_ROWS
public static java.lang.String clobToString(java.sql.Clob clob)
throws DBSQLException,
java.sql.SQLException
DBSQLExceptionjava.sql.SQLExceptionpublic static int update(java.sql.Connection connection,
java.lang.String sql)
throws DBSQLException
sql - is the sql update to send to the databaseDBSQLExceptionpublic static int update(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
throws DBSQLException
sql - is the sql update query to send to the databaseDBSQLExceptionpublic static int insert(java.sql.Connection dbConnection,
java.lang.String sql)
throws DBSQLException
dbConnection - an open database connectionsql - is the sql insert query to send to the databaseDBSQLExceptionpublic static int insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql)
throws DBSQLException
sql - is the sql insert query to send to the databaseDBSQLExceptionpublic static int insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
throws DBSQLException
sql - is the sql insert query to send to the databaseDBSQLExceptionpublic static int insertAndReturnKey(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params,
ISqlTable sqlTable)
throws DBSQLException
sql - is the sql insert query to send to the databaseparams - - these will be used as paramaters in a PreparedStatementsqlTable - - if not null the pk value will be used in the prepared statement constructior to ne specific about which field is the PK.DBSQLExceptionpublic static int insert(java.sql.Connection dbConnection,
java.lang.String sql,
java.util.List<SqlField> params)
throws DBSQLException
sql - is the sql insert query to send to the databaseDBSQLExceptionpublic int[] batch(java.sql.Connection dbConnection,
java.lang.String[] batch)
throws java.sql.SQLException
dbConnection - is the open database connectionbatch - is an array of sql commands usually update and or insertjava.sql.SQLExceptionpublic java.lang.String query(java.sql.Connection connection,
java.lang.String sql)
throws java.sql.SQLException
connection - the db connectionsql - is the sql query to send to the databasejava.sql.SQLExceptionpublic java.lang.String query(java.sql.ResultSet rs)
throws java.sql.SQLException
rs - is the resultSet from the queryjava.sql.SQLExceptionpublic static java.lang.String queryOne(java.sql.Connection connection,
java.lang.String sql,
java.util.List<SqlField> params)
throws DBSQLException
connection - an open database connectionsql - is the query.DBSQLExceptionpublic static java.lang.String queryOne(java.sql.ResultSet rs)
throws DBSQLException,
java.sql.SQLException
rs - is the resultSet with the executed query.DBSQLExceptionjava.sql.SQLExceptionpublic java.lang.String queryXML(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName)
throws DBSQLException
connection - an open db connectionsql - is the sql query to send to the databaseDBSQLExceptionpublic java.lang.String queryXML(java.sql.ResultSet rs,
java.lang.String rootName)
throws DBSQLException,
java.sql.SQLException
DBSQLExceptionjava.sql.SQLExceptionpublic java.lang.String queryXMLShort(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName)
throws DBSQLException
connection - an open database connectionsql - is the database query to executerootName - is an optional root element name used to wrap the resultant
xml rows.DBSQLExceptionpublic java.lang.String queryXMLShort(java.sql.Connection connection,
java.lang.String sql,
java.lang.String rootName,
java.util.List<SqlField> params)
throws DBSQLException
connection - an open database connectionsql - is the database query to executerootName - is an optional root element name used to wrap the resultant
xml rows.DBSQLExceptionpublic java.lang.String queryXMLShort(java.sql.ResultSet rs,
java.lang.String rootName)
throws java.sql.SQLException,
DBSQLException
rs - is the ResultSet we use to retrieve the data a row at a timerootName - is the root element namejava.sql.SQLExceptionDBSQLExceptionpublic java.lang.String queryXMLShort(java.sql.ResultSet rs,
java.lang.String rootName,
java.lang.String dateFormat)
throws DBSQLException,
java.sql.SQLException
rs - is the ResultSet we use to retrieve the data a row at a timerootName - is the root element namedateFormat - is the date format we want for all dates, default is
"dd-MM-yyyy"DBSQLExceptionjava.sql.SQLExceptionpublic java.lang.String queryXMLShort(java.sql.ResultSet rs,
java.lang.String[] elementNames,
java.lang.String rootName,
java.lang.String dateFormat)
throws java.sql.SQLException
rs - is the ResultSet we use to retrieve the data a row at a timeelementNames - is a corresponding name for each attributerootName - is the root element namedateFormat - is the date format we want for all dates, default is "dd-MM-yyyy"java.sql.SQLExceptionpublic java.lang.String queryXMLLong(java.sql.ResultSet rs,
java.lang.String[] elementNames,
java.lang.String rootName,
java.lang.String dateFormat)
throws java.sql.SQLException
rs - is the ResultSet we use to retrieve the data a row at a timeelementNames - is a corresponding name for each elementrootName - is the root element namedateFormat - is the date format we want for all dates, default is "dd-MM-yyyy"java.sql.SQLExceptionpublic XMLObject query2XMLObject(java.sql.Connection connection, java.lang.String sql, java.lang.String rootName, java.lang.String[] elementNames, java.lang.String dateFormat, java.util.List<SqlField> params) throws DBSQLException
connection - is the database connectionsql - is the sql queryrootName - is the root element name. this is mandatoryelementNames - is a corresponding name for each element, if this is null then
the label names will be used instead.dateFormat - is the date format we want for all dates, if this is null then
the default is "dd-MM-yyyy"DBSQLExceptionDBSQLExceptionpublic XMLObject query2XMLObject(java.sql.ResultSet rs, java.lang.String rootName, java.lang.String[] elementNames, java.lang.String dateFormat) throws java.sql.SQLException
rs - is the ResultSet we use to retrieve the data a row at a timeelementNames - is a corresponding name for each element, if this is null then the label names will be used instead.rootName - is the root element name. this is mandatorydateFormat - is the date format we want for all dates, if this is null then the defaultDateFormat is used. @see
defaultDateFormatjava.sql.SQLExceptionpublic static java.lang.String escCharacters(java.lang.String input)
input - string for storage into a databasepublic void setIncludeIndex(boolean includeIndex)
public boolean isIncludeIndex()