2010-08-15 101 views

回答

3

做什麼如下:

莫名其妙地讓你的網頁的HTML到字符串變量:

String fullHtml = ""; 

使用JDBC與文本字段

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

插入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(); 

你完成了。

1

在MySQL中使用text類型。然後使用簡單的Statement/PreparedStatement插入文本。

我所建議的雖然是在數據庫之外有一個html模板,並用從數據庫中獲得的特定數據填充它。

0

如果您要在數據庫中放入完整的HTML頁面,您可能需要查看壓縮字段。應該得到相當大的空間節省...

相關問題