How can we insert full HTML of a webpage into my table using Java?
3 Answers
Do what follows:
Get your page's HTML somehow into a String variable:
String fullHtml = "";
Create a table with a text field
create table your_html_container (
id int primary key autoincrement,
content text not null
);
Insert html content using JDBC:
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();
You are done.