Guest User

Untitled

a guest
Nov 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. CREATE TABLE DATES(
  2. DT DATETIME,
  3. TS TIMESTAMP,
  4. );
  5.  
  6. INSERT INTO DATES(DT, TS) VALUES(NOW(), NOW());
  7.  
  8. SELECT * FROM DATES;
  9.  
  10. try{
  11. Class.forName("com.mysql.jdbc.Driver");
  12. Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/MYDB","root","pswrd");
  13. Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
  14. ResultSet srs = stmt.executeQuery("SELECT * FROM DATES");
  15. }
  16. catch(Exception e){
  17. e.printStackTrace();
  18. JOptionPane.showMessageDialog(null, "Error.");
  19. }
  20.  
  21. JOptionPane.showMessageDialog(null, "Date & Time: " + <<I want the values here>>);
Add Comment
Please, Sign In to add comment