http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/rowset/CachedRowSet.html http://www.onjava.com/pub/a/onjava/2004/06/23/cachedrowset.html http://java.sun.com/products/jdbc/download.html#rowset1_0_1
解决方案 »
- 传递对象
- 多少线程问题
- 对答案不理解,希望得到帮住
- 如何使上传图像等比例缩小?UP有分
- ##A question, Why????##
- 我装完j2se后设置为:path:D:\liuwenxi\j2se\bin,classpath:D:\liuwenxi\j2se\lib\tools.jar;D:\liuwenxi\j2se\lib\dt.jar
- 请问有没有ini文件操作的类?
- 简单问题,请给我一个解释。立即给分。
- 为什么resultset.last()说是抽象方法错?
- 找代码和文档(java)
- rmi的codebase问题。Stub无法自动下载
- 请问如何在j2se桌面程序中调用Excel的打印功能....在线等候...
import java.util.Collections;
import java.util.Hashtable;
import java.util.Vector;import javax.sql.rowset.CachedRowSet;import com.sun.rowset.CachedRowSetImpl;import rule.db.*;public class TableInstance { public TableInstance(Vector c, ISet iSet, int k) throws SQLException {
int start = DbTools.getTableStartId(); Connection conn = DBConnection.getConnection();
Statement stmt = conn.createStatement();
conn.setAutoCommit(false); for (int i = 0; i < c.size(); i++) {
String type = (String) c.elementAt(i);
/*
* stmt.execute("INSERT INTO TBL_TYPES (K, TYPE) VALUES (" + k + ", " +
* type + ")");
*/
start = start + i + 1;
String tblName = "T" + start;
stmt.execute("CREATE TABLE " + tblName + "(" + type
+ " INTEGER, id integer)");
stmt
.execute("INSERT INTO TBL_TBLNAMES (ID, K, TABLENAME, TYPESTR) VALUES ("
+ start
+ ", "
+ k
+ ", '"
+ tblName
+ "', '"
+ type + "')");
// for (int j = 0; j < iSet.getInstanceNumber(); j++) {
Vector ids = iSet.getIdByType(type);
for (int z = 0; z < ids.size(); z++) {
int id = ((Integer) ids.elementAt(z)).intValue();
stmt.execute("INSERT INTO " + tblName + "(" + type
+ ", id) values(" + id + ", 0)");
}
// }
}
conn.commit();
stmt.close();
} public TableInstance(InterfaceEPC epc, Vector c, TableInstance tk, int k)
throws SQLException {
// get max used serial number
int start = DbTools.getTableStartId();
// ---end of get max used serial number // print c
/*
* System.out
* .println("=====================================================");
* System.out.println("k=" + k); for (int h = 0; h < c.size(); h++) {
* Vector hhh = (Vector) c.elementAt(h);
* System.out.println(hhh.toString()); } System.out
* .println("=====================================================");
*/
// ---end print c
Connection conn = null;
Statement stmt = null;
//conn.setAutoCommit(false); for (int i = 0; i < c.size(); i++) {
conn = DBConnection.getConnection();
stmt = conn.createStatement();
conn.setAutoCommit(false);
Vector types = (Vector) c.elementAt(i);
// System.out.println("k=" + k + ",types=" + types.toString());
Collections.sort(types); // sort types by type name
String typeStr = Rule.vectorToString(types); // typeStr used to
// get table name
int tblId = start + i + 1; // get a table serial number
String tblName = "T" + tblId; // generate a new table name
StringBuffer sql = new StringBuffer(); // create table sql
StringBuffer sql2 = new StringBuffer(); // create index sql
sql.append("CREATE TABLE ").append(tblName).append(" (");
sql2.append("CREATE UNIQUE INDEX IDX_").append(tblName).append(
" ON ").append(tblName).append("(");
System.out.println("--->types=" + types.toString());
// use all type as column name
for (int j = 0; j < k + 1; j++) {
String type = (String) types.elementAt(j);
//System.out.println("--->type=" + type + ", j=" + j);
sql.append(type).append(" INTEGER, ");
sql2.append(type).append(",");
}
sql.append(" ID INTEGER)");
String sql2Str = sql2.toString();