Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

select list of values from db java

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 by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #select #list #values #db #java
ADD COMMENT
Topic
Name
1+2 =