Java SQL Table Exist tableExist(Statement stmt, String tablename)

Here you can find the source of tableExist(Statement stmt, String tablename)

Description

table Exist

License

Open Source License

Declaration

public static boolean tableExist(Statement stmt, String tablename) 

Method Source Code

//package com.java2s;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {

    public static boolean tableExist(Statement stmt, String tablename) {
        ResultSet result = null;//from  w ww  . j av  a 2  s  .c om
        try {
            result = stmt
                    .executeQuery("select count(*) from sqlite_master where type='table' and name = 'develop'");
            while (result.next()) {
                if (result.getInt(1) == 1) {
                    return true;
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (result != null) {
                try {
                    result.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
        return false;
    }
}

Related

  1. tableExists(Connection con, String table)
  2. tableExists(Connection con, String tableName)
  3. tableExists(Connection conn, String name)
  4. tableExists(Connection conn, String tableName)