Example usage for java.sql ResultSet close

List of usage examples for java.sql ResultSet close

Introduction

In this page you can find the example usage for java.sql ResultSet close.

Prototype

void close() throws SQLException;

Source Link

Document

Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

Usage

From source file:SerializeJavaObjects_MySQL.java

public static Object readJavaObject(Connection conn, long id) throws Exception {
    PreparedStatement pstmt = conn.prepareStatement(READ_OBJECT_SQL);
    pstmt.setLong(1, id);/*from ww  w.  j a va2  s  .  c om*/
    ResultSet rs = pstmt.executeQuery();
    rs.next();
    Object object = rs.getObject(1);
    String className = object.getClass().getName();

    rs.close();
    pstmt.close();
    System.out.println("readJavaObject: done de-serializing: " + className);
    return object;
}

From source file:Main.java

public static void close(ResultSet rs) {
    try {//www  . ja  va2 s  .c o m
        if (rs != null) {
            rs.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static Object readJavaObject(Connection conn, long id) throws Exception {
    PreparedStatement pstmt = conn.prepareStatement(READ_OBJECT_SQL);
    pstmt.setLong(1, id);/*from w  ww.ja  v a2  s .co m*/
    ResultSet rs = pstmt.executeQuery();
    rs.next();
    Object object = rs.getObject("object_value");
    String className = object.getClass().getName();
    rs.close();
    pstmt.close();
    return object;
}

From source file:com.nabla.wapp.server.database.Database.java

public static void close(final ResultSet rs) {
    try {/* w w  w .  ja va  2  s  .  c om*/
        rs.close();
    } catch (final SQLException e) {
    }
}

From source file:TestDB.java

 /**
 * Runs a test by creating a table, adding a value, showing the table contents, and removing the
 * table./*  ww  w  .j ava2 s . c om*/
 */
public static void runTest() throws SQLException, IOException
{
   Connection conn = getConnection();
   try
   {
      Statement stat = conn.createStatement();

      stat.executeUpdate("CREATE TABLE Greetings (Message CHAR(20))");
      stat.executeUpdate("INSERT INTO Greetings VALUES ('Hello, World!')");

      ResultSet result = stat.executeQuery("SELECT * FROM Greetings");
      if (result.next())
         System.out.println(result.getString(1));
      result.close();
      stat.executeUpdate("DROP TABLE Greetings");
   }
   finally
   {
      conn.close();
   }
}

From source file:com.alibaba.napoli.metamorphosis.client.consumer.storage.JDBCUtils.java

public static void close(ResultSet rs) {
    if (rs != null) {
        try {//from   w  w  w .  ja v  a2  s . co  m
            rs.close();
        } catch (SQLException ex) {
            log.error("Close ResultSet failed", ex);
        }
    }
}

From source file:com.googlecode.flyway.core.util.jdbc.JdbcUtils.java

/**
 * Safely closes this resultSet. This method never fails.
 *
 * @param resultSet The resultSet to close.
 *///www.j a  va2  s.c  o  m
public static void closeResultSet(ResultSet resultSet) {
    if (resultSet == null) {
        return;
    }

    try {
        resultSet.close();
    } catch (SQLException e) {
        LOG.error("Error while closing Jdbc resultSet", e);
    }
}

From source file:net.mlw.vlh.adapter.jdbc.util.JdbcUtil.java

/** Cleans up resources.
 * //from   www  .java 2  s  .  c o  m
 * @param result ResultSet to close.
 * @param statement Statement to close.
 * @param connection Connection to close.
 */
public static void close(ResultSet result, Statement statement, Connection connection) {
    if (result != null)
        try {
            result.close();
        } catch (Exception ignore) {
            LOGGER.info(ignore);
        }
    if (statement != null)
        try {
            statement.close();
        } catch (Exception ignore) {
            LOGGER.info(ignore);
        }
    if (connection != null)
        try {
            connection.close();
        } catch (Exception ignore) {
            LOGGER.info(ignore);
        }
}

From source file:jeeves.utils.IO.java

public static void closeQuietly(ResultSet rs) {
    if (rs != null) {
        try {// w ww . ja  v a  2  s.  co  m
            rs.close();
        } catch (Throwable t) {
            // ignore
        }
    }
}

From source file:com.ibm.research.rdf.store.runtime.service.sql.UpdateHelper.java

private static void closeSQLObjects(PreparedStatement stmt, ResultSet rs) {
    try {/*from  w w  w. ja  v a2 s  .c  o  m*/
        if (rs != null)
            rs.close();
    } catch (SQLException e) {
    }

    try {
        if (stmt != null)
            stmt.close();
    } catch (SQLException e) {
    }
}