Java SQL Time getMaxPollTime(final Connection jdbcConnection, final String tableName)

Here you can find the source of getMaxPollTime(final Connection jdbcConnection, final String tableName)

Description

get Max Poll Time

License

Apache License

Declaration

public static int getMaxPollTime(final Connection jdbcConnection,
            final String tableName) throws SQLException 

Method Source Code

//package com.java2s;
/*/*from w w w  .  j a  v a2s  .c  om*/
 * Copyright 2013-2015 Lakshmisha Bhat
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.sql.*;
import java.text.MessageFormat;

public class Main {
    public static int getMaxPollTime(final Connection jdbcConnection,
            final String tableName) throws SQLException {
        int maxRow = 0;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            stmt = jdbcConnection.createStatement();
            String sql = MessageFormat.format(
                    "SELECT max(polltime) as maxpoll FROM {0}", tableName);
            rs = stmt.executeQuery(sql);
            if (rs.next()) {
                maxRow = rs.getInt("maxpoll");
            }
        } finally {
            cleanupAfterQuery(rs, stmt);
        }
        return maxRow;
    }

    private static void cleanupAfterQuery(final ResultSet rs,
            final Statement stmt) throws SQLException {
        if (rs != null) {
            rs.close();
        }
        if (stmt != null) {
            stmt.close();
        }
    }
}

Related

  1. getGrandfatheredTime()
  2. getIntervalDays(Date time1, Date time2)
  3. getJoinedSysDateTime()
  4. getLastTimeOfDay(Calendar calendar)
  5. getMaxModifyTime(String path)
  6. getServerTime()
  7. getServerTimezone(Properties dbSettings)
  8. getSGWDateTime(long dateTime)
  9. getSQLDate(long datetime)