Select List Of Values From Db Java

[Solved] Select List Of Values From Db Java | Scala - Code Explorer | yomemimo.com
Question : select list of values from db java

Answered by :

public static ArrayList<Customer> getAllCustomer() throws ClassNotFoundException, SQLException { Connection conn=DBConnection.getDBConnection().getConnection(); Statement stm; stm = conn.createStatement(); String sql = "Select * From Customer"; ResultSet rst; rst = stm.executeQuery(sql); ArrayList<Customer> customerList = new ArrayList<>(); while (rst.next()) { Customer customer = new Customer(rst.getString("id"), rst.getString("name"), rst.getString("address"), rst.getDouble("salary")); customerList.add(customer); } return customerList;
}

Source : https://stackoverflow.com/questions/11983554/reading-data-from-database-and-storing-in-array-list-object | Last Update : Mon, 06 Jun 22

Answers related to select list of values from db java

Code Explorer Popular Question For Scala