学习了数据库的分区操作在 Java 中的应用
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class JavaMySQLPartitionExample {
public static void main(String[] args) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase", "username", "password");
String sql = "INSERT INTO partitioned_table (column1, column2) VALUES (?,?)";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, "value1");
ps.setString(2, "value2");
ps.executeUpdate();
con.close();
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
}
}