Here you can find the source of getResultSet(Connection connection, String query)
Parameter | Description |
---|---|
connection | connection object |
query | custom query |
Parameter | Description |
---|---|
SQLException | throws an exception if an error occurs |
public static ResultSet getResultSet(Connection connection, String query) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class Main { /**/* w w w . j a v a2 s . c o m*/ * to get a result set of a query * * @param connection * connection object * @param query * custom query * @return a result set of custom query * @throws SQLException * throws an exception if an error occurs */ public static ResultSet getResultSet(Connection connection, String query) throws SQLException { ResultSet rs; PreparedStatement st = connection.prepareStatement(query); rs = st.executeQuery(); return rs; } }