MySQL Table Exists - Java java.sql

Java examples for java.sql:MySQL

Description

MySQL Table Exists

Demo Code


//package com.java2s;

import java.sql.*;

public class Main {
    public static boolean TableExists(Connection dbConn, String tableName) {
        Statement statement = null;
        ResultSet resultSet = null;

        try {//from   ww w. j av  a  2  s  . c  o m
            statement = dbConn.createStatement();
            resultSet = statement.executeQuery("SELECT * FROM " + tableName
                    + " LIMIT 1");
        } catch (SQLException ex) {
            return false;
        }

        return true;
    }
}

Related Tutorials