Guest User

Untitled

a guest
Jul 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1.  
  2. package main;
  3.  
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.sql.Statement;
  9.  
  10.  
  11.  
  12. public class test_class
  13. {
  14.  
  15. public static void main(String[] args){
  16. Connection conn = null;
  17. try {
  18. conn = DriverManager.getConnection("jdbc:mysql://localhost/world?" + "user=root&password=warpten");
  19.  
  20.  
  21. Statement stmt = null;
  22. ResultSet rs = null;
  23. // Do something with the Connection
  24. stmt = conn.createStatement();
  25. rs = stmt.executeQuery("SELECT * FROM city");
  26.  
  27. // or alternatively, if you don't know ahead of time that
  28. // the query will be a SELECT...
  29.  
  30. if (stmt.execute("SELECT * FROM city")) {
  31. rs = stmt.getResultSet();
  32.  
  33. }
  34. System.out.print("FFFFFFFFFFF");
  35.  
  36. } catch (SQLException ex) {
  37. // handle any errors
  38. System.out.println("SQLException: " + ex.getMessage());
  39. System.out.println("SQLState: " + ex.getSQLState());
  40. System.out.println("VendorError: " + ex.getErrorCode());
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment