本文整理匯總了Java中javax.sql.rowset.CachedRowSet.setMetaData方法的典型用法代碼示例。如果您正苦於以下問題:Java CachedRowSet.setMetaData方法的具體用法?Java CachedRowSet.setMetaData怎麽用?Java CachedRowSet.setMetaData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sql.rowset.CachedRowSet
的用法示例。
在下文中一共展示了CachedRowSet.setMetaData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initCoffeeHousesMetaData
import javax.sql.rowset.CachedRowSet; //導入方法依賴的package包/類
private void initCoffeeHousesMetaData(CachedRowSet crs) throws SQLException {
RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);
/*
* CREATE TABLE COFFEE_HOUSES(
* STORE_ID Integer NOT NULL,
* CITY VARCHAR(32),
* COFFEE INTEGER NOT NULL,
* MERCH INTEGER NOT NULL,
* TOTAL INTEGER NOT NULL,
* PRIMARY KEY (STORE_ID))
*/
rsmd.setColumnCount(COFFEE_HOUSES_COLUMN_NAMES.length);
for(int i = 1; i <= COFFEE_HOUSES_COLUMN_NAMES.length; i++){
rsmd.setColumnName(i, COFFEE_HOUSES_COLUMN_NAMES[i-1]);
rsmd.setColumnLabel(i, rsmd.getColumnName(i));
}
rsmd.setColumnType(1, Types.INTEGER);
rsmd.setColumnType(2, Types.VARCHAR);
rsmd.setColumnType(3, Types.INTEGER);
rsmd.setColumnType(4, Types.INTEGER);
rsmd.setColumnType(5, Types.INTEGER);
crs.setMetaData(rsmd);
crs.setTableName(COFFEE_HOUSES_TABLE);
}
示例2: initCoffeesMetaData
import javax.sql.rowset.CachedRowSet; //導入方法依賴的package包/類
protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException {
RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);
/*
* CREATE TABLE COFFEES (
* COF_ID INTEGER NOT NULL,
* COF_NAME VARCHAR(32) NOT NULL,
* SUP_ID INTEGER NOT NULL,
* PRICE NUMBERIC(10,2 NOT NULL,
* SALES INTEGER NOT NULL,
* TOTAL INTEGER NOT NULL,
* PRIMARY KEY (COF_ID),
* FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) )
*/
rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length);
for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){
rsmd.setColumnName(i, COFFEES_COLUMN_NAMES[i-1]);
rsmd.setColumnLabel(i, rsmd.getColumnName(i));
}
rsmd.setColumnType(1, Types.INTEGER);
rsmd.setColumnType(2, Types.VARCHAR);
rsmd.setColumnType(3, Types.INTEGER);
rsmd.setColumnType(4, Types.NUMERIC);
rsmd.setPrecision(4, 10);
rsmd.setScale(4, 2);
rsmd.setColumnType(5, Types.INTEGER);
rsmd.setColumnType(6, Types.INTEGER);
crs.setMetaData(rsmd);
crs.setTableName(COFFEES_TABLE);
}
示例3: initDataTypesMetaData
import javax.sql.rowset.CachedRowSet; //導入方法依賴的package包/類
protected void initDataTypesMetaData(CachedRowSet crs) throws SQLException {
RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);
rsmd.setColumnCount(DATATYPES_COLUMN_NAMES.length);
for (int i = 1; i <= DATATYPES_COLUMN_NAMES.length; i++) {
rsmd.setColumnName(i, DATATYPES_COLUMN_NAMES[i - 1]);
rsmd.setColumnLabel(i, rsmd.getColumnName(i));
}
rsmd.setColumnType(1, Types.INTEGER);
rsmd.setColumnType(2, Types.CHAR);
rsmd.setColumnType(3, Types.VARCHAR);
rsmd.setColumnType(4, Types.BIGINT);
rsmd.setColumnType(5, Types.BOOLEAN);
rsmd.setColumnType(6, Types.SMALLINT);
rsmd.setColumnType(7, Types.DOUBLE);
rsmd.setColumnType(8, Types.DECIMAL);
rsmd.setColumnType(9, Types.REAL);
rsmd.setColumnType(10, Types.TINYINT);
rsmd.setColumnType(11, Types.DATE);
rsmd.setColumnType(12, Types.TIME);
rsmd.setColumnType(13, Types.TIMESTAMP);
rsmd.setColumnType(14, Types.VARBINARY);
rsmd.setColumnType(15, Types.ARRAY);
rsmd.setColumnType(16, Types.REF);
rsmd.setColumnType(17, Types.FLOAT);
crs.setMetaData(rsmd);
}
示例4: initSuppliersMetaData
import javax.sql.rowset.CachedRowSet; //導入方法依賴的package包/類
private void initSuppliersMetaData(CachedRowSet crs) throws SQLException {
RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl();
/*
* CREATE TABLE SUPPLIERS (
* SUP_ID INTEGER NOT NULL,
* SUP_NAME VARCHAR(32) NOT NULL,
* STREET VARCHAR(32) NOT NULL,
* CITY VARCHAR(32) NOT NULL,
* STATE CHAR(2) NOT NULL,
* ZIP CHAR(5) NOT NULL,
* PRIMARY KEY (SUP_ID))
*/
rsmd.setColumnCount(6);
rsmd.setColumnName(1, "SUP_ID");
rsmd.setColumnName(2, "SUP_NAME");
rsmd.setColumnName(3, "STREET");
rsmd.setColumnName(4, "CITY");
rsmd.setColumnName(5, "STATE");
rsmd.setColumnName(6, "ZIP");
rsmd.setColumnType(1, Types.INTEGER);
rsmd.setColumnType(2, Types.VARCHAR);
rsmd.setColumnType(3, Types.VARCHAR);
rsmd.setColumnType(4, Types.VARCHAR);
rsmd.setColumnType(5, Types.CHAR);
rsmd.setColumnType(6, Types.CHAR);
crs.setMetaData(rsmd);
crs.setTableName(SUPPLIERS_TABLE);
}