sqlutil.java
来自「J2EE独立开发制作」· Java 代码 · 共 40 行
JAVA
40 行
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 + =
减小字号Ctrl + -
显示快捷键?