Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class Main {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Connection connect;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- String serverName = "localhost",
- databaseName = "it-learning",
- url = "jdbc:mysql://" + serverName + "/" + databaseName,
- user = "root",
- password = "";
- connect = DriverManager.getConnection(url, user, password);
- String query = "SELECT * FROM courses";
- Statement statement = connect.createStatement();
- ResultSet set = statement.executeQuery(query);
- while (set.next()) {
- System.out.println(set.getString("icon"));
- }
- connect.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement