一个JDBC表控件模型 - 编程入门网
TableModel (conn, tableName);
JTable jtable = new JTable (mod);
JScrollPane scroller =
new JScrollPane (jtable,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JFrame frame = new JFrame ("JDBCTableModel demo");
frame.getContentPane().add (scroller);
frame.pack();
frame.setVisible (true);
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static String createSampleTable (Connection conn)
throws SQLException {
Statement statement = conn.createStatement();
// drop table if it exists
try {
statement.execute ("DROP TABLE EMPLOYEES");
} catch (SQLException sqle) {
sqle.printStackTrace(); // if table !exists
}
statement.execute ("CREATE TABLE EMPLOYEES " +
"(Name CHAR(20), Title CHAR(30), Salary INT)");
statement.execute ("INSERT INTO EMPLOYEES VALUES " +
"(''Jill'', ''CEO'', 200000 )");
statement.execute ("INSERT INTO EMPLOYEES VALUES " +
"(''Bob'', ''VP'', 195000 )");
statement.execute ("INSERT INTO EMPLOYEES VALUES " +
"(''Omar'', ''VP'', 190000 )");
statement.execute ("INSERT INTO EMPLOYEES VALUES " +
"(''Amy'', ''Software Engineer'', 50000 )");
statement.execute ("INSERT INTO EMPLOYEES VALUES " +
"(''Greg'', ''Software Engineer'', 45000 )");
statement.close();
return "EMPLOYEES";
}
}
createSampleTable()圭隈祥頁低俶勣嶷亟議栖峨秘低徭協吶方象議圭隈。糞縞貧?喇噐万卦指議頁低侭幹秀議燕議燕兆?低俶勣壓方象垂嶄幹秀俯謹音揖議燕栖霞編庁侏泌採侃尖麿断。賜宀旋喘匯倖儉桟伏撹謹佩方象旺拝心廾墮宸乂方象俶勣謹海扮寂。 恷朔?輝低塰佩殻會議扮昨?TestJDBCTable伏撹阻匯倖揮嗤方象垂燕議坪否議JFrame?泌夕3-9侭幣。 夕3-9.繍方象垂嶄議方象野割欺Jtable嶄 Joshua Marinacci頁java.net貧" The Java Sketchbook "議廨生恬社?袈律膚式Java人薩極才利大園殻。 Chris Adamson頁ONJava才java.net議園辞?冉蒙声寄綱諒?麼好Java?Mac荷恬狼由X才謹箪悶園殻。 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |