我正在尝试从oracle数据库中获取一些数据,并尝试发送邮件。我希望行和列适合表结构。所以我在想一个HTML表格。我怎样才能在Java Bean
本身做同样的事情。这是我的代码:
<@
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
conn=odiRef.getJDBCConnection("SRC");
Statement stmt=conn.createStatement();
String result="";
char delimiter=(char)9;
String line="";
result+="SESS_NAME"+delimiter+"STEP_NO"+delimiter+"SESS_STATUS"+delimiter+"SESSION_END_TIME"+delimiter+"SESSION_DURATION"+(char)13;
my_query="select * from odi_mon";
ResultSet rs=stmt.executeQuery(my_query);
ResultSetMetaData md=rs.getMetaData();
int numColumns =md.getColumnCount();
for(int j=0;j<70;j++){
line+="_";
}
result+=line+(char)13;
while (rs.next()) {
for (int i=1; i<numColumns+1; i++) {
String output=rs.getString(md.getColumnName(i))+delimiter;
result+=output;
}
result=result.substring(0,result.length()-1);
result+=line+(char)13;
result+=(char)13;
}
// Close Connection
stmt.close();
conn.close();
@>