Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- /**
- * Created by yasin_000 on 15.11.2017.
- */
- public class Database {
- static final String JDBC = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:mysql://localhost:3306/world";
- public static void main(String[] args) {
- try {
- Class.forName(JDBC);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- try (Connection connection = DriverManager.getConnection(DB_URL, "root", "951753yasin@@");
- PreparedStatement statement = connection.prepareStatement("SELECT * FROM country WHERE population < 10000");
- ResultSet resultSet = statement.executeQuery()){
- while(resultSet.next())
- System.out.println(resultSet.getString("Name"));
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment