1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Connection conn = null;
try { conn = DriverManager.getConnection("jdbc:mysql://localhost/hearing?" + "user=root&password=pass1234&serverTimezone=UTC");
String user ="test@gmail.com"; PreparedStatement st = conn.prepareStatement("SELECT * FROM Customer WHERE Email = ?"); st.setString(1,user); ResultSet ret = st.executeQuery(); while(ret.next()) { System.out.println(ret.getString("FirstName")); System.out.println(ret.getString("Created")); } } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); }
|