Java SQL Query executeQuery(Connection c, String query)

Here you can find the source of executeQuery(Connection c, String query)

Description

executeQuery

License

Open Source License

Parameter

Parameter Description
c c
query query

Exception

Parameter Description
SQLException SQLException

Return

DOCUMENT ME!

Declaration

public static ResultSet executeQuery(Connection c, String query) throws SQLException 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
    /**//from   w  ww.ja  va2 s .c o m
     * executeQuery
     * 
     * @param c
     *            c
     * @param query
     *            query
     * 
     * @return DOCUMENT ME!
     * 
     * @throws SQLException
     *             SQLException
     */
    public static ResultSet executeQuery(Connection c, String query) throws SQLException {
        ResultSet rs = null;
        Statement st = null;

        try {
            st = c.createStatement();
            rs = st.executeQuery(query);
        } catch (SQLException ee) {
            if (st != null) {
                st.close();
            }

            if (rs != null) {
                try {
                    rs.close();
                } catch (Exception eee) {
                }
            }
            throw ee;
        }
        return rs;
    }
}

Related

  1. createInQueryStatement(String query, long[] ids, Connection conn)
  2. executeCsvQuery(Connection csv, String csvTableName)
  3. executeDDL(String query, Connection connection)
  4. executeForResult(Connection conn, String query, String... args)
  5. ExecuteNoneQuerys(String cmdtext, Object[] parms)
  6. ExecuteQuery(Connection conn, PreparedStatement preparedStatement, PreparedStatement lockStatement, String tablename)
  7. executeQuery(Connection connection)
  8. executeQuery(Connection connection, String query)
  9. executeQuery(Connection dbConnection, String selectString)