Java学习之路-SQL-用jdbc连接MySql

用jdbc技术实现连接mysql数据库。
SQL/Test1.java

package cn.antraces.SQL;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Test1 {
    public static void main (String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://127.0.0.1:3306/mysql?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT", "root", "wodiu");
        System.out.println(connection);
    }
}
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注