Here you can find the source of getWaitTimeout(Connection con)
private static long getWaitTimeout(Connection con)
//package com.java2s; /*/*from ww w.java 2 s . co m*/ * This file is part of RuneSource. * * RuneSource is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RuneSource is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RuneSource. If not, see <http://www.gnu.org/licenses/>. */ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static long getWaitTimeout(Connection con) { Statement stmt = null; ResultSet rs = null; try { stmt = con.createStatement(); rs = stmt.executeQuery("SHOW VARIABLES LIKE 'wait_timeout'"); if (rs.next()) { return Math.max(1000, rs.getInt(2) * 1000 - 1000); } else { return -1; } } catch (SQLException ex) { return -1; } finally { close(rs); close(stmt); } } public static void close(ResultSet rs) { try { rs.close(); } catch (Exception e) { } } public static void close(Statement stmt) { try { stmt.close(); } catch (Exception e) { } } public static void close(Connection conn) { try { conn.close(); } catch (Exception e) { } } }