这可能是一个非常基本的问题,但 stackoverflow 如何存储用户发布的代码片段?每个片段是否只是一个带有文本字段和 userid + postid 的数据库条目?
最佳答案
我查看了不同 Stack Overflow question 的 HTML 代码.
<p>I'm making a program in java that makes queries into SQL and show the result in a jtable, my problem is if i do Insert, delete or update i want my jtable to show the sql table that was modified, is there any function for that?
This is my method to execute the query:</p>
<pre><code> public void executequery() {
try {
String userQuery = Query.getText();
Statement statement;
statement = conn.createStatement();
statement.execute(userQuery);
ResultSet rs = statement.executeQuery(userQuery);
//in case of a instert, delete or update i want to show
//the modified sql on my jtable
table.setModel(DbUtils.resultSetToTableModel(rs));
rs.close();
statement.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
</code></pre>
您在这里有几个选择。
您可以使用问题 ID + 用户 ID 作为键将 HTML + 文本保存在数据库中。
您可以使用类型指示器分别保存文本和代码,并使用该指示器创建您的 HTML。
两种方法都行。
关于database - stackoverflow 如何存储代码片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40561230/