All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.antiaction.raptor.sql.SqlResult Maven / Gradle / Ivy

The newest version!
package com.antiaction.raptor.sql;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * A simple SQL wrapper for keeping track of query SQL, statement and the
 * result.
 */
public class SqlResult {

	/** Logging mechanism. */
	private static Logger logger = Logger.getLogger(SqlResult.class.getName());

	/** Query SQL. */
	public String sql = null;

	/** SQL statement. */
	public PreparedStatement stm = null;

	/** Query ResultSet. */
	public ResultSet rs = null;

	/** Row count returned by some SQL executions. */
	public int res = 0;

	public SqlResult(Connection conn, String sql) throws SQLException {
		stm = conn.prepareStatement( sql );
	}

	/**
	 * Close resources related to this query.
	 */
	public void close() {
		try {
			if (rs != null) {
				rs.close();
			}
		}
		catch (SQLException e) {
			logger.log(Level.SEVERE, e.toString(), e);
		}
		rs = null;
		try {
			if (stm != null) {
				stm.close();
			}
		}
		catch (SQLException e) {
			logger.log(Level.SEVERE, e.toString(), e);
		}
		stm = null;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy