|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.ed.inf.utils.database.SqlUtils
public class SqlUtils
Class
| Field Summary | |
|---|---|
static int |
DOUBLE
Basic data type: double (passes without error a parseDouble action) |
static int |
INTEGER
Basic data type: integer (passes without error a parseInteger action) |
static int |
MAX_BIGINT_LENGTH
Maximum length in characters for a signed SQL INT BIGINT[(M)] A large integer. |
static int |
MAX_CHAR_LENGTH
Maximum length in characters for an SQL CHAR column CHAR(M) A fixed-length string. |
static int |
MAX_INT_LENGTH
Maximum length in characters for a signed SQL INT INT[(M)] A normal-size integer. |
static int |
NULL
Basic data type: null (the type could not be guessed, eg. |
static int |
STRING
Basic data type: string (anything that is not an integer or a double...) |
| Constructor Summary | |
|---|---|
SqlUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
getSelectStarSql(java.lang.String table)
Generates a select * query text (eg. |
static java.lang.String |
getSelectWhereEqualSql(java.lang.String table,
java.lang.String column,
java.lang.String equalityConditionValue)
gets sql code for a select on one column of a table, with a where x = y condition specific for that column |
static java.lang.String |
getSelectWhereEqualSql(java.lang.String table,
java.lang.String column1,
java.lang.String equalityConditionValue1,
java.lang.String column2,
java.lang.String equalityConditionValue2)
Select on two columns of a table, with two "where" conditions, , one for each provided column |
static java.lang.String |
getSelectWhereLikeSql(java.lang.String table,
java.lang.String column,
java.lang.String equalityConditionValue)
Gets sql code for a select on one column of a table, with a where x like y condition specific for that column |
static java.lang.String |
getSelectWhereSql(java.lang.String table,
java.lang.String column,
java.lang.String whereCondition)
gets sql code for a select on one column of a table, with a where condition |
static java.lang.String |
getSimpleSelectSql(java.lang.String table,
java.lang.String column)
gets sql code for a select on one column of a table |
static java.lang.String |
getSqlForSelectLike(java.lang.String table,
java.lang.String column,
java.lang.String likeColumn,
java.lang.String likeCondition)
Sql code for a select "LIKE" |
static java.lang.String |
getSqlSelectByIdByRegExp(java.lang.String table,
java.lang.String valueColumn,
java.lang.String idColumn,
java.lang.String id,
java.lang.String regExp)
Generates the sql command for a select of a value corresponding to a certain id AND matching a certain regex string |
static java.lang.String |
getSqlSelectByRegExp(java.lang.String table,
java.lang.String column,
java.lang.String regExp)
Generates the sql command for a select matching a certain regex string |
static java.lang.String |
getSqlToDropTable(java.lang.String tableName)
Get sql to drop table |
static java.lang.String |
surroundWith(java.lang.String text,
java.lang.String surrounding)
Adds a surrounding string (usually an apex or similar) as prefix and suffix of the given text. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DOUBLE
public static final int INTEGER
public static final int MAX_BIGINT_LENGTH
public static final int MAX_CHAR_LENGTH
public static final int MAX_INT_LENGTH
public static final int NULL
public static final int STRING
| Constructor Detail |
|---|
public SqlUtils()
| Method Detail |
|---|
public static java.lang.String getSelectStarSql(java.lang.String table)
table -
public static java.lang.String getSelectWhereEqualSql(java.lang.String table,
java.lang.String column,
java.lang.String equalityConditionValue)
table - the table to select fromcolumn - the column to select fromequalityConditionValue - the x value for the: where column = 'x' condition.
public static java.lang.String getSelectWhereEqualSql(java.lang.String table,
java.lang.String column1,
java.lang.String equalityConditionValue1,
java.lang.String column2,
java.lang.String equalityConditionValue2)
table - the table to select fromcolumn1 - the column to select fromequalityConditionValue1 - the x1 value for the: where column1 = 'x1' condition.column2 - the column to select fromequalityConditionValue2 - the x2 value for the: where column2 = 'x2' condition.
public static java.lang.String getSelectWhereLikeSql(java.lang.String table,
java.lang.String column,
java.lang.String equalityConditionValue)
table - the table to select fromcolumn - the column to select fromsimilarityConditionValue - the x value for the: where column like '%x%' condition.
public static java.lang.String getSelectWhereSql(java.lang.String table,
java.lang.String column,
java.lang.String whereCondition)
table - the table to select fromcolumn - the column to select from
public static java.lang.String getSimpleSelectSql(java.lang.String table,
java.lang.String column)
table - the table to select fromcolumn - the column to select from
public static java.lang.String getSqlForSelectLike(java.lang.String table,
java.lang.String column,
java.lang.String likeColumn,
java.lang.String likeCondition)
table - the table to select fromcolumn - the column to select fromlikeColumn - the x variable for the "where x like y" sql statementlikeCondition - the y variable for the "where x like y" sql statement
public static java.lang.String getSqlSelectByIdByRegExp(java.lang.String table,
java.lang.String valueColumn,
java.lang.String idColumn,
java.lang.String id,
java.lang.String regExp)
table - the table to select fromvalueColumn - the column to select data fromidColumn - the column that contains the id to select byid - the single id to select byregExp - a regular expression pattern (check your database syntax for
details)
public static java.lang.String getSqlSelectByRegExp(java.lang.String table,
java.lang.String column,
java.lang.String regExp)
table - the table to select fromcolumn - the column to select data fromregExp - a regular expression pattern (check your database syntax for
details)
public static java.lang.String getSqlToDropTable(java.lang.String tableName)
public static java.lang.String surroundWith(java.lang.String text,
java.lang.String surrounding)
text - string to be surroundedsurrounding - a string to use as prefix and suffix (for example, an apex)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||