Here you can find the source of executeQuery(String sql, String[] parameters)
public static ResultSet executeQuery(String sql, String[] parameters)
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { private static Connection ct = null; private static PreparedStatement ps = null; private static ResultSet rs = null; private static String url = ""; private static String username = ""; private static String password = ""; public static ResultSet executeQuery(String sql, String[] parameters) { try {/*from w w w. j a v a2s . co m*/ ct = getConnection(); ps = ct.prepareStatement(sql); if (parameters != null) { for (int i = 0; i < parameters.length; i++) { ps.setString(i + 1, parameters[i]); } } rs = ps.executeQuery(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } return rs; } public static Connection getConnection() { try { ct = DriverManager.getConnection(url, username, password); } catch (Exception e) { e.printStackTrace(); } return ct; } }