String url = “jdbc:mysql://hostname:port/databasename?characterEncoding=UTF-8”;
String username = “your-username”;
String password = “your-password”;
try {
// 加载 JDBC 驱动程序
Class.forName("com.mysql.jdbc.Driver");
// 建立数据库连接
Connection connection = DriverManager.getConnection(url, username, password);
// 创建 Statement 对象
Statement statement = connection.createStatement();