1
我得到了一切正常,並打印正確的結果報頭(列名)和值。不過,我想將普通和無組織的結果更改爲非常好的輸出表格式,就像查詢中帶有虛線的MySql表結果一樣。我怎麼做?Java SQL輸出格式表結果
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM quarter");
ResultSetMetaData rsMetaData = rs.getMetaData();
int numberOfColumns = rsMetaData.getColumnCount();
for(int i = 1; i <= numberOfColumns; i++)
{
System.out.print(rsMetaData.getColumnLabel(i) + " ");
}
System.out.println();
while (rs.next())
{
for(int e = 1; e <= rsMetaData.getColumnCount(); e++)
{
System.out.print(rs.getString(e) + " ");
}
System.out.println();
}