Java SQL Key isKeyAnInteger(Connection dbConn)

Here you can find the source of isKeyAnInteger(Connection dbConn)

Description

is Key An Integer

License

Open Source License

Declaration

public static boolean isKeyAnInteger(Connection dbConn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;
import java.sql.ResultSet;

import java.sql.Statement;
import java.sql.Types;

public class Main {
    public static boolean isKeyAnInteger(Connection dbConn) {
        Statement stmt = null;/*  w  w w  .  j  a v a 2s  . co  m*/
        ResultSet rs = null;
        boolean isInt = false;
        try {
            stmt = dbConn.createStatement();
            rs = stmt.executeQuery("SELECT Key FROM Indexer LIMIT 1");
            int type = rs.getMetaData().getColumnType(1);
            isInt = type == Types.BIGINT;
        } catch (Exception e) {
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (stmt != null)
                    stmt.close();
            } catch (Exception e) {
            }
        }
        return isInt;
    }
}

Related

  1. getData(String key)
  2. getForeignKeys(String toTable, Connection con, boolean force)