Java SQL Table getCount(Connection conn, String tableName)

Here you can find the source of getCount(Connection conn, String tableName)

Description

get Count

License

Open Source License

Declaration

public static int getCount(Connection conn, String tableName) throws SQLException 

Method Source Code


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

import java.sql.Connection;

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

public class Main {
    public static int getCount(Connection conn, String tableName) throws SQLException {
        String sql = "select count(*) from " + tableName;
        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery(sql);
        rset.next();//w w  w  .ja va 2s.  co  m
        int count = rset.getInt(1);
        rset.close();
        stmt.close();
        return count;
    }
}

Related

  1. dumpTableToFile(Connection con, String table, String fileName)
  2. exportTableData(String tableName, Connection con)
  3. getAllTableNames(Connection connection)
  4. getAllTables(Connection conn)
  5. getBatchResultMessage(String tableName, int rowIdx, int resultCode)
  6. getIdNumber(String tableName)
  7. getImmutableDefaults()
  8. getLastCreatedEntry(Connection conn, String tableName)
  9. getMetaDataMap(Statement statement, String tableOrViewName)