try
{
Connection conn = DriverManager.getConnection"jdbc:odbc:ChatHistory2");
Statement stmt = conn.createStatement();
String sql = "SELECT Name, Date, Content FROM Chat";
ResultSet rs = stmt.executeQuery(sql);
int iCountRow = 0;
while(rs.next())
{
sName = rs.getString("Name");
sDate = rs.getString("Date");
sContent = rs.getString("Content");
// 显示数据
table.add
table.setValueAt(sName,iCountRow,0);
table.setValueAt(sDate,iCountRow,1);
table.setValueAt(sContent,iCountRow,2);
iCountRow++;
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
{
Connection conn = DriverManager.getConnection"jdbc:odbc:ChatHistory2");
Statement stmt = conn.createStatement();
String sql = "SELECT Name, Date, Content FROM Chat";
ResultSet rs = stmt.executeQuery(sql);
int iCountRow = 0;
while(rs.next())
{
sName = rs.getString("Name");
sDate = rs.getString("Date");
sContent = rs.getString("Content");
// 显示数据
table.add
table.setValueAt(sName,iCountRow,0);
table.setValueAt(sDate,iCountRow,1);
table.setValueAt(sContent,iCountRow,2);
iCountRow++;
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货