Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) throws Exception {
  9.  
  10. // Accessing driver from the JAR file
  11. Class.forName("com.mysql.jdbc.Driver");
  12.  
  13. // Creating a variable for the connection called "con"
  14. Connection conn = DriverManager.getConnection("jdbc:mysql://184.154.73.113:3306", "davidlno_student",
  15. "ez24get!");
  16. // Hostname: 184.154.73.113
  17. // Port: 3306
  18. // Username: davidlno_student
  19. // Password: ez24get!
  20.  
  21. PreparedStatement statement = conn.prepareStatement("select * from TickerHistory");
  22.  
  23. ResultSet result = statement.executeQuery();
  24.  
  25. while (result.next()) {
  26. System.out.println(result.getString(1) + " " + result.getString(2));
  27. } // end while
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement