Java DataSource tableRecommendationExistsHsqdb(DataSource dataSource)

Here you can find the source of tableRecommendationExistsHsqdb(DataSource dataSource)

Description

table Recommendation Exists Hsqdb

License

Apache License

Declaration

private static boolean tableRecommendationExistsHsqdb(DataSource dataSource) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.DataSource;

public class Main {
    private static boolean tableRecommendationExistsHsqdb(DataSource dataSource) {
        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
                return false;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }/* w  w  w  . java 2  s  .  c o m*/
    }
}

Related

  1. purgeTables(DataSource ds)
  2. registerSpringDataSource(String name, DataSource dataSource)
  3. selectCount(DataSource ds, String tableName)
  4. setUpJndiDatasource()
  5. sqlExe(DataSource dataSource, String sql)
  6. update(DataSource dataSource, String sql, Object params[])
  7. update_Db(DataSource ds, String query)
  8. waitUntilDatabaseIsAvailable(DataSource dataSource, int timeoutSeconds)