📄 sqlutil.java
字号:
package test;
import java.sql.*;
public class SQLUtil{
public static synchronized String getHtmlRows(ResultSet results)
throws SQLException{
StringBuffer htmlRows = new StringBuffer();
ResultSetMetaData metaData = results.getMetaData();
int columnCount = metaData.getColumnCount();
htmlRows.append("<tr>");
for (int i = 1; i <= columnCount; i++)
htmlRows.append("<td><b>" + metaData.getColumnName(i) + "</td>");
htmlRows.append("</tr>");
while (results.next()){
htmlRows.append("<tr>");
for (int i = 1; i <= columnCount; i++)
htmlRows.append("<td>" + results.getString(i) + "</td>");
}
htmlRows.append("</tr>");
return htmlRows.toString();
}
public static synchronized String encode(String s){
if (s == null) return s;
StringBuffer sb = new StringBuffer(s);
for (int i = 0; i < sb.length(); i++){
char ch = sb.charAt(i);
if (ch == 39){
sb.insert(i++, "'");
}
}
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -