|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.stratelia.webactiv.util.DBUtil
public class DBUtil
Nested Class Summary | |
---|---|
static class |
DBUtil.SelectResultRowProcessor<ROW_ENTITY>
Result Set Row Processor |
Method Summary | ||
---|---|---|
static StringBuilder |
appendListOfParameters(StringBuilder sqlQuery,
Collection<?> parameters)
Centralization in order to build easily a SQL in clause. |
|
static StringBuilder |
appendListOfParameters(StringBuilder sqlQuery,
Collection<?> parameters,
Collection<?> allParameters)
Centralization in order to build easily a SQL in clause. |
|
static
|
appendParameter(StringBuilder sqlQuery,
String sqlPart,
O paramValue,
Collection<O> parameters)
Centralization in order to populate the prepare statement parameters. |
|
static
|
appendSaveParameter(StringBuilder sqlQuery,
String paramName,
O paramValue,
boolean isInsert,
Collection<O> parameters)
Centralization in order to populate the prepare statement parameters. |
|
static void |
clearTestInstance()
|
|
static void |
close(Connection connection)
|
|
static void |
close(ResultSet rs)
|
|
static void |
close(ResultSet rs,
Statement st)
|
|
static void |
close(Statement st)
|
|
static
|
executeUpdate(Connection con,
List<org.apache.commons.lang3.tuple.Pair<String,List<O>>> updateQueries)
Update query executor. |
|
static long |
executeUpdate(Connection con,
String updateQuery,
Object... parameters)
|
|
static long |
executeUpdate(Connection con,
String updateQuery,
Object parameters)
Update query executor. |
|
static Set<String> |
getAllTableNames()
Gets all table names. |
|
static int |
getDateFieldLength()
|
|
static Date |
getDateFromLong(ResultSet resultSet,
int index)
Gets a Date value from a Long value from a current result set. |
|
static DBUtil |
getInstance()
|
|
static DBUtil |
getInstanceForTest(Connection connectionForTest)
|
|
static Long |
getLong(ResultSet resultSet,
int index)
Gets a long value from a current result set. |
|
static int |
getMaxFromTable(Connection con,
String tableName,
String idName)
|
|
protected static int |
getMaxId(Connection privateConnection,
String tableName,
String idName)
|
|
static int |
getNextId(Connection connection,
String tableName,
String idName)
Return a new unique Id for a table. |
|
static int |
getNextId(String tableName,
String idName)
Return a new unique Id for a table. |
|
static int |
getTextAreaLength()
|
|
static int |
getTextFieldLength()
|
|
static int |
getTextMaxiLength()
|
|
static String |
getUniqueId()
Returns a new unique identifier of type string. |
|
static boolean |
isSqlDefined(String sqlValue)
Indicates if the specified value is defined in point of view of SQL. |
|
static Connection |
makeConnection(String dbName)
fabrique une nouvelle connection |
|
static void |
rollback(Connection connection)
|
|
static
|
select(Connection con,
String updateQuery,
Object parameters,
DBUtil.SelectResultRowProcessor<ROW_ENTITY> rowProcess)
Update query executor. |
|
static
|
selectCount(Connection con,
String selectCountQuery,
Collection<O> params)
Select count SQL query executor. |
|
static
|
selectCount(Connection con,
String selectCountQuery,
O idParam)
Select count SQL query executor. |
|
static
|
setParameters(PreparedStatement preparedStatement,
Collection<O> parameters)
Centralization in order to sets the parameters on a prepare statement. |
|
static
|
unique(List<ENTITY> entities)
Gets from a entity list the unique entity expected. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int getDateFieldLength()
public static int getTextMaxiLength()
public static int getTextAreaLength()
public static int getTextFieldLength()
public static DBUtil getInstance()
public static DBUtil getInstanceForTest(Connection connectionForTest)
public static void clearTestInstance()
public static Connection makeConnection(String dbName)
dbName
- le nom de la base de donnée
UtilException
public static String getUniqueId()
public static int getNextId(String tableName, String idName) throws UtilException
tableName
- the name of the table.idName
- the name of the column.
UtilException
public static int getNextId(Connection connection, String tableName, String idName) throws SQLException
connection
- the JDBC connection.tableName
- the name of the table.idName
- the name of the column.
SQLException
protected static int getMaxId(Connection privateConnection, String tableName, String idName) throws SQLException
SQLException
public static int getMaxFromTable(Connection con, String tableName, String idName)
public static void close(ResultSet rs, Statement st)
public static void close(Statement st)
public static void close(ResultSet rs)
public static void close(Connection connection)
public static void rollback(Connection connection)
public static Set<String> getAllTableNames()
public static boolean isSqlDefined(String sqlValue)
sqlValue
- the value to verify.
public static <O> long selectCount(Connection con, String selectCountQuery, O idParam) throws SQLException
con
- selectCountQuery
- idParam
-
SQLException
public static <O> long selectCount(Connection con, String selectCountQuery, Collection<O> params) throws SQLException
con
- selectCountQuery
- params
-
SQLException
public static <ROW_ENTITY> List<ROW_ENTITY> select(Connection con, String updateQuery, Object parameters, DBUtil.SelectResultRowProcessor<ROW_ENTITY> rowProcess) throws SQLException
con
- updateQuery
- parameters
-
SQLException
public static <ENTITY> ENTITY unique(List<ENTITY> entities)
entities
- the entity list.
IllegalArgumentException
- if it exists more than one entity in the specified
list.public static <O> long executeUpdate(Connection con, List<org.apache.commons.lang3.tuple.Pair<String,List<O>>> updateQueries) throws SQLException
con
- updateQueries
-
SQLException
public static long executeUpdate(Connection con, String updateQuery, Object... parameters) throws SQLException
SQLException
public static long executeUpdate(Connection con, String updateQuery, Object parameters) throws SQLException
con
- updateQuery
- parameters
-
SQLException
public static <O> StringBuilder appendSaveParameter(StringBuilder sqlQuery, String paramName, O paramValue, boolean isInsert, Collection<O> parameters)
sqlQuery
- paramName
- paramValue
- isInsert
- parameters
-
public static <O> StringBuilder appendParameter(StringBuilder sqlQuery, String sqlPart, O paramValue, Collection<O> parameters)
sqlQuery
- sqlPart
- parameters
-
public static StringBuilder appendListOfParameters(StringBuilder sqlQuery, Collection<?> parameters)
sqlQuery
- parameters
-
public static StringBuilder appendListOfParameters(StringBuilder sqlQuery, Collection<?> parameters, Collection<?> allParameters)
sqlQuery
- parameters
- allParameters
-
public static <O> void setParameters(PreparedStatement preparedStatement, Collection<O> parameters) throws SQLException
preparedStatement
- parameters
-
SQLException
public static Long getLong(ResultSet resultSet, int index) throws SQLException
resultSet
- index
-
SQLException
public static Date getDateFromLong(ResultSet resultSet, int index) throws SQLException
resultSet
- index
-
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |