Java examples for java.sql:ResultSet
release JDBC Resource
//package com.java2s; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static void release(Object o) { if (o == null) { return; }/*from w ww .j av a 2 s . c o m*/ if (o instanceof ResultSet) { try { ((ResultSet) o).close(); } catch (SQLException e) { e.printStackTrace(); } } else if (o instanceof Statement) { try { ((Statement) o).close(); } catch (SQLException e) { e.printStackTrace(); } } else if (o instanceof Connection) { Connection c = (Connection) o; try { if (!c.isClosed()) { c.close(); } } catch (SQLException e) { e.printStackTrace(); } } } public static void release(ResultSet rs, Statement stmt, Connection conn) { release(rs); release(stmt); release(conn); } }