Java SQL ResultSet cleanupJDBCResouce(ResultSet rs, Statement stmt, String oldCatalog, Connection conn)

Here you can find the source of cleanupJDBCResouce(ResultSet rs, Statement stmt, String oldCatalog, Connection conn)

Description

cleanup JDBC Resouce

License

Open Source License

Declaration

static public void cleanupJDBCResouce(ResultSet rs, Statement stmt, String oldCatalog, Connection conn) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 NexB Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /*from   w ww .j av a  2 s .c  o m*/
 * Contributors:
 *     Anton Safonov and Ahti Kitsik - initial API and implementation
 *******************************************************************************/

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
    static public void cleanupJDBCResouce(ResultSet rs, Statement stmt, String oldCatalog, Connection conn) {
        try {
            if (rs != null)
                rs.close();
        } catch (SQLException e) {
            // TODO log properly JDBCASEPlugin.getDefault().log(e);
            e.printStackTrace();
        }
        try {
            if (stmt != null)
                stmt.close();
        } catch (SQLException e) {
            // TODO log properly JDBCASEPlugin.getDefault().log(e);
            e.printStackTrace();
        }
        try {
            if (oldCatalog != null)
                conn.setCatalog(oldCatalog);
        } catch (SQLException e) {
            // TODO log properly JDBCASEPlugin.getDefault().log(e);
            e.printStackTrace();
        }
    }
}

Related

  1. arrayOfResult(ResultSet rs)
  2. cleanupAfterQuery(final ResultSet rs, final Statement stmt)
  3. cleanupConnection(ResultSet rs, Statement stmt, Connection conn)
  4. consume(ResultSet rs)
  5. consume2(ResultSet rs)
  6. copyInt(ResultSet rs, int sourcePos, PreparedStatement stmt, int destPos)
  7. createLargeResultSetPreparedStatement(Connection conn, String sql)