Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- web application servlet to query and display user information from mysql
- id | first name | last name | address | telephone number
- public void init () throws ServletException {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/membership","root","");
- stmt = conn.createStatement();
- } catch (ClassNotFoundException ex) { // for Class.forName()
- ex.printStackTrace();
- } catch (SQLException ex) { // for getConnection()
- ex.printStackTrace();
- }
- }
- String query = "SELECT * FROM member WHERE xxx ";
- ResultSet rset = stmt.executeQuery(query);
- while (rs.next()) {
- int ID = rs.getInt("id");
- String fName = rs.getString("first_name");
- String lName = rs.getString("last_name");
- String address = rs.getString("address");
- String phone = rs.getString("telephone_number");
- }
Add Comment
Please, Sign In to add comment