Guest User

Untitled

a guest
Nov 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. /**
  4. * Created by yasin_000 on 15.11.2017.
  5. */
  6. public class Database {
  7. static final String JDBC = "com.mysql.jdbc.Driver";
  8. static final String DB_URL = "jdbc:mysql://localhost:3306/world";
  9.  
  10.  
  11. public static void main(String[] args) {
  12. try {
  13. Class.forName(JDBC);
  14. } catch (ClassNotFoundException e) {
  15. e.printStackTrace();
  16. }
  17. try (Connection connection = DriverManager.getConnection(DB_URL, "root", "951753yasin@@");
  18. Statement statement = connection.createStatement();
  19. ResultSet resultSet = statement.executeQuery("SELECT * FROM country")){
  20. while(resultSet.next())
  21. System.out.println(resultSet.getString("Name"));
  22. } catch (SQLException e1) {
  23. e1.printStackTrace();
  24. }
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment