run Query and get ResultSet - Java java.sql

Java examples for java.sql:ResultSet

Description

run Query and get ResultSet

Demo Code


//package com.java2s;
import java.sql.*;

public class Main {
    private static ResultSet runQuery(Connection connection, String query) {
        try {/*from ww w  .  jav  a 2s .c o m*/
            Statement statement = connection.createStatement(
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_UPDATABLE,
                    ResultSet.HOLD_CURSORS_OVER_COMMIT);
            ResultSet resultSet = statement.executeQuery(query);

            return (resultSet);

        } catch (SQLException sqle) {
            System.err.println("Error executing query: " + sqle);
            return (null);
        }
    }
}

Related Tutorials