Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.darwinsys.sql;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import com.darwinsys.database.DataBaseException;
/** Miscellaneous utilities for dealing with SQL.
* XXX Consider replacing with ResultSetDecoratorHTML
* @author ian
*/
public class SQLUtils {
/**
* Process resultset, formatting it as HTML
* @param rs The valid ResultSet, which will be closed.
* @param out A PrintWriter to generate HTML to.
* @param titleStyle CSS style name for title row (may be same as style1)
* @param style1 CSS style name for title and data rows 2, 4, 6, ...
* @param style2 CSS style name for data rows 1, 3, 5, ...
* @param keyColName The name of the key column
* @param link The base URL
* @throws SQLException If the database reports an error
*/
public static void resultSetToHTML(
final ResultSet rs, final PrintWriter out,
String titleStyle, String style1, String style2,
String keyColName, String link)
throws SQLException {
ResultSetMetaData md = rs.getMetaData();
int count = md.getColumnCount();
out.println("
");
// Print a table row with column headings.
out.printf("
", titleStyle);
for (int i=1; i<=count; i++) {
out.printf("
%s%n", md.getColumnName(i));
}
out.println("
");
// Print one table row of data for each row in the resultset.
int rowNum = 0;
while (rs.next()) {
out.printf("