Java Utililty Methods DataSource

List of utility methods to do DataSource

Description

The list of methods to do DataSource are organized into topic(s).

Method

booleantableRecommendationExistsHsqdb(DataSource dataSource)
table Recommendation Exists Hsqdb
try (Connection connection = dataSource.getConnection()) {
    PreparedStatement stmt = connection.prepareStatement(
            "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.SYSTEM_TABLES WHERE TABLE_NAME = ?");
    stmt.setString(1, "RECOMMENDATION");
    ResultSet rs = stmt.executeQuery();
    if (rs.next()) {
        return rs.getString(1) != null;
    } else
...
intupdate(DataSource dataSource, String sql, Object params[])
update
Connection connection = getConn(dataSource);
PreparedStatement preparedStatement = null;
int ret = 0;
try {
    preparedStatement = connection.prepareStatement(sql);
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            preparedStatement.setObject(i + 1, params[i]);
...
intupdate_Db(DataSource ds, String query)
updat Db
Connection conn = null;
Statement stmt = null;
int updated = 0;
try {
    conn = ds.getConnection();
    stmt = conn.createStatement();
    updated = stmt.executeUpdate(query);
} catch (SQLException e) {
...
voidwaitUntilDatabaseIsAvailable(DataSource dataSource, int timeoutSeconds)
Waits until timeout is reached or the database is available.
long start = System.currentTimeMillis();
long timeout = timeoutSeconds * 1000;
boolean started = false;
while (!started) {
    Connection connection = null;
    Statement statement = null;
    try {
        connection = dataSource.getConnection();
...