public class SqlUtil extends Object implements Serializable
| Modifier | Constructor and Description |
|---|---|
protected |
SqlUtil(int dbms) |
| Modifier and Type | Method and Description |
|---|---|
Object |
bool(boolean value) |
Object |
bool(String value)
Oracle DOES NOT SUPPORT Boolean, so this method returns 1 or 0 (or null).
|
Date |
date(String fieldName,
String value)
convert a value to a sql.Date
|
void |
defDate(String fieldname,
String dateFormat)
define the format for a date field
|
void |
defNumber(String fieldname,
String numberFormat)
define the format for a number field
|
void |
defSequence(String fieldname,
String sequenceName)
define the call that a field gets its value from a sequence
|
static SqlUtil |
forConnection(Connection connection)
Ermittele die Datenbank anhand der MetaData der Connection
|
static SqlUtil |
forHSQLDB()
create an instance for HSQLDB syntax (affects sequences)
|
static SqlUtil |
forOracle()
create an instance for oracle syntax (affects sequences)
|
static SqlUtil |
forPostgres()
create an instance for postgres syntax (affects sequences)
|
Object |
get(String fieldName)
get the call for the given field.
|
static SqlUtil |
getDefault() |
boolean |
isHSQLDB() |
boolean |
isOracle() |
boolean |
isPostgres() |
boolean |
isTrue(String value) |
long |
nextVal(Connection connection,
String fieldName)
fetch the next value of the sequence, defined under this name
|
String |
nullable(String value) |
Number |
number(String fieldName,
String value) |
Time |
time(String fieldName,
String value) |
Timestamp |
timestamp(String fieldName,
String value) |
String |
trim(String value)
a null-aware trim function
|
public static SqlUtil forConnection(Connection connection) throws SQLException
SQLExceptionpublic boolean isOracle()
public boolean isPostgres()
public boolean isHSQLDB()
public static SqlUtil forPostgres()
public static SqlUtil forOracle()
public static SqlUtil forHSQLDB()
public static SqlUtil getDefault()
public void defDate(String fieldname, String dateFormat)
fieldname - - symbolic field namedateFormat - - java.text.SimpleDateFormat patternpublic void defNumber(String fieldname, String numberFormat)
fieldname - - symbolic field namenumberFormat - - java.text.DecimalFormat patternpublic void defSequence(String fieldname, String sequenceName)
fieldname - - symbolic field namesequenceName - - name of the sequence to be usedpublic Date date(String fieldName, String value) throws ParseException
fieldName - - symbolic field name (must have a format registered with defDate())value - - text value to be parsed to date, can be "" or nullParseExceptionpublic Timestamp timestamp(String fieldName, String value) throws ParseException
ParseExceptionpublic Time time(String fieldName, String value) throws ParseException
ParseExceptionpublic Number number(String fieldName, String value) throws ParseException
ParseExceptionpublic boolean isTrue(String value)
public Object bool(String value)
value - null (for null), "1" (for true), "0" (for false), "true" (for true), "false" (for false)public Object bool(boolean value)
public long nextVal(Connection connection, String fieldName) throws SQLException
SQLExceptionpublic Object get(String fieldName)
fieldName - - symbolic field nameParseExceptionCopyright © 2008-2016. All Rights Reserved.