Here you can find the source of getMaxPollTime(final Connection jdbcConnection, final String tableName)
public static int getMaxPollTime(final Connection jdbcConnection, final String tableName) throws SQLException
//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(); } } }