Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Java :: Fix arabic javafx 
Java :: thread implements runnable 
Java :: method parameters in java 
Java :: java letter to number 
Java :: java Convert a string IPv4 IP address to the equivalent long numeric value. 
Java :: array of arrays java 
Java :: How to merge two sorted arrays into a single sorted aggregate one? 
Java :: jaccard index two vectors R 
Java :: lcm of two large positive integers java 
Java :: convert linkedlist to integer array java 
Java :: java print 2d array row and column 
Java :: startactivity not working in android adapter 
Java :: java Math.sqrt(double) 
Java :: osmdroid get current zoom level 
Java :: java interface 
Java :: double to string in java without tovalue 
Java :: what is use of drivermanager class 
Java :: observer pattern java 
Java :: java synchronized method 
Java :: how to translate java swing 
Java :: JFrame change outline 
Java :: could not load main class java 
Java :: java stack verification failed 
Java :: Java Create a ByteArrayInputStream 
Java :: android studio find all views in layout 
Java :: how to insert a 0 in an array java 
Java :: java wrapper classes 
Java :: java double 
Java :: java store data 
Java :: convert alphabet to number in java 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =