package cn.reghao.tnb.sb.db.mybatis.test.jdbc;

import java.sql.*;

/**
 * @author reghao
 * @date 2022-01-28 10:31:43
 */
public class JdbcTest {
    static String driver = "com.mysql.cj.jdbc.Driver";
    static String url = "jdbc:mysql://localhost:3306/reghao_spider_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8";
    static String username = "dev";
    static String password = "Dev@123456";

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        Statement stmt = conn.createStatement();

        String sql = "select * from url_resource limit 100";
        ResultSet rs = stmt.executeQuery(sql);
        while (rs.next()) {
            int id = rs.getInt("id");
            String url = rs.getString("url");
            System.out.printf("%s: %s%n\n", id, url);
        }

        rs.close();
        stmt.close();
        conn.close();
    }
}
