gpt4 book ai didi

java - 如何使用 Java 在 MySQL DB 中插入 HTML?

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:07 24 4
gpt4 key购买 nike

我们如何使用 Java 将网页的完整 HTML 插入到我的表格中?

最佳答案

执行以下操作:

以某种方式将页面的 HTML 放入字符串变量中:

String fullHtml = "";

创建一个带有文本字段的表格

create table your_html_container (
id int primary key autoincrement,
content text not null
);

使用 JDBC 插入 html 内容:

Connection conn = DriverManager.getConnection(connectionURL, user, password);
PreparedStatement pstmt =
conn.prepareStatement("insert into your_html_container (content) values (?)");
pstmt.setString(1, fullHtml); // this is your html string from step #1
pstmt.executeUpdate();
pstmt.close();
conn.close();

你已经完成了。

关于java - 如何使用 Java 在 MySQL DB 中插入 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3487567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com