本文整理匯總了Java中javax.sql.RowSet類的典型用法代碼示例。如果您正苦於以下問題:Java RowSet類的具體用法?Java RowSet怎麽用?Java RowSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RowSet類屬於javax.sql包,在下文中一共展示了RowSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: commonCachedRowSetTest0043
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0043(RowSet rs) throws Exception {
assertFalse(rs.isAfterLast());
assertFalse(rs.isLast());
rs.afterLast();
assertTrue(rs.isAfterLast());
assertFalse(rs.isLast());
rs.previous();
assertFalse(rs.isAfterLast());
assertTrue(rs.isLast());
rs.previous();
assertFalse(rs.isAfterLast());
assertFalse(rs.isLast());
rs.last();
assertFalse(rs.isAfterLast());
assertTrue(rs.isLast());
rs.close();
}
示例2: commonCachedRowSetTest0007
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0007(RowSet rs) throws Exception {
TestRowSetListener rsl = new TestRowSetListener();
TestRowSetListener rsl2 = new TestRowSetListener();
rs.addRowSetListener(rsl);
rs.addRowSetListener(rsl2);
rs.first();
rs.updateInt(1, 1961);
rs.updateString(2, "Pittsburgh");
rs.updateInt(3, 1987);
rs.updateInt(4, 2341);
rs.updateInt(5, 6689);
rs.updateRow();
assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED
| TestRowSetListener.ROW_CHANGED));
assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED
| TestRowSetListener.ROW_CHANGED));
rs.close();
}
示例3: commonCachedRowSetTest0042
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0042(RowSet rs) throws Exception {
assertFalse(rs.isBeforeFirst());
assertFalse(rs.isFirst());
rs.beforeFirst();
assertTrue(rs.isBeforeFirst());
assertFalse(rs.isFirst());
rs.next();
assertFalse(rs.isBeforeFirst());
assertTrue(rs.isFirst());
rs.next();
assertFalse(rs.isBeforeFirst());
assertFalse(rs.isFirst());
rs.first();
assertFalse(rs.isBeforeFirst());
assertTrue(rs.isFirst());
rs.close();
}
示例4: testBug5188
import javax.sql.RowSet; //導入依賴的package包/類
/**
* Tests fix for BUG#5188, CachedRowSet errors using PreparedStatement. Uses
* Sun's "com.sun.rowset.CachedRowSetImpl"
*
* @throws Exception
*/
public void testBug5188() throws Exception {
String implClass = "com.sun.rowset.CachedRowSetImpl";
Class<?> c;
Method populate;
try {
c = Class.forName(implClass);
} catch (ClassNotFoundException e) {
System.out.println("skipping testBug5188. Requires: " + implClass);
return;
}
populate = c.getMethod("populate", new Class[] { ResultSet.class });
createTable("testBug5188", "(ID int NOT NULL AUTO_INCREMENT, datafield VARCHAR(64), PRIMARY KEY(ID))");
this.stmt.executeUpdate("INSERT INTO testBug5188(datafield) values('test data stuff !')");
String sql = "SELECT * FROM testBug5188 where ID = ?";
this.pstmt = this.conn.prepareStatement(sql);
this.pstmt.setString(1, "1");
this.rs = this.pstmt.executeQuery();
// create a CachedRowSet and populate it
RowSet cachedRowSet = (RowSet) c.newInstance();
// cachedRowSet.populate(rs);
populate.invoke(cachedRowSet, new Object[] { this.rs });
// scroll through CachedRowSet ...
assertTrue(cachedRowSet.next());
assertEquals("1", cachedRowSet.getString("ID"));
assertEquals("test data stuff !", cachedRowSet.getString("datafield"));
assertFalse(cachedRowSet.next());
}
示例5: evaluate
import javax.sql.RowSet; //導入依賴的package包/類
public boolean evaluate(RowSet rs) {
boolean result = false;
if (rs == null) {
return false;
}
try {
for (String city : cities) {
String val = "";
if (colNumber > 0) {
val = (String) rs.getObject(colNumber);
} else if (colName != null) {
val = (String) rs.getObject(colName);
}
if (val.equalsIgnoreCase(city)) {
return true;
}
}
} catch (SQLException e) {
result = false;
}
return result;
}
示例6: rowSetScrollTypes
import javax.sql.RowSet; //導入依賴的package包/類
@DataProvider(name = "rowSetScrollTypes")
protected Object[][] rowSetScrollTypes() throws Exception {
RowSet rs = newInstance();
return new Object[][]{
{rs, ResultSet.TYPE_FORWARD_ONLY},
{rs, ResultSet.TYPE_SCROLL_INSENSITIVE},
{rs, ResultSet.TYPE_SCROLL_SENSITIVE}
};
}
示例7: rowsetUsingCoffeeHouses
import javax.sql.RowSet; //導入依賴的package包/類
@DataProvider(name = "rowsetUsingCoffeeHouses")
protected Object[][] rowsetUsingCoffeeHouses() throws Exception {
RowSet rs = createCoffeeHousesRowSet();
return new Object[][]{
{rs}
};
}
示例8: initDataTypesMetaData
import javax.sql.RowSet; //導入依賴的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);
}
示例9: createCoffeeHousesRowSet
import javax.sql.RowSet; //導入依賴的package包/類
protected <T extends RowSet> T createCoffeeHousesRowSet() throws SQLException {
T rs = (T) newInstance();
initCoffeeHousesMetaData((CachedRowSet) rs);
createCoffeeHouseRows(rs);
// Make sure you are not on the insertRow
rs.moveToCurrentRow();
return rs;
}
示例10: commonRowSetTest0006
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0006(RowSet rs) throws Exception {
rs.setUrl(url);
rs.setDataSourceName(dsName);
assertTrue(rs.getDataSourceName().equals(dsName));
assertNull(rs.getUrl());
}
示例11: createDataTypesRows
import javax.sql.RowSet; //導入依賴的package包/類
protected void createDataTypesRows(RowSet crs) throws SQLException {
Integer aInteger = 100;
String aChar = "Oswald Cobblepot";
Long aLong = Long.MAX_VALUE;
Short aShort = Short.MAX_VALUE;
Double aDouble = Double.MAX_VALUE;
BigDecimal aBigDecimal = BigDecimal.ONE;
Boolean aBoolean = false;
Float aFloat = Float.MAX_VALUE;
Byte aByte = Byte.MAX_VALUE;
Date aDate = Date.valueOf(LocalDate.now());
Time aTime = Time.valueOf(LocalTime.now());
Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
Array aArray = new StubArray("INTEGER", new Object[1]);
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
byte[] bytes = new byte[10];
crs.moveToInsertRow();
crs.updateInt(1, aInteger);
crs.updateString(2, aChar);
crs.updateString(3, aChar);
crs.updateLong(4, aLong);
crs.updateBoolean(5, aBoolean);
crs.updateShort(6, aShort);
crs.updateDouble(7, aDouble);
crs.updateBigDecimal(8, aBigDecimal);
crs.updateFloat(9, aFloat);
crs.updateByte(10, aByte);
crs.updateDate(11, aDate);
crs.updateTime(12, aTime);
crs.updateTimestamp(13, aTimeStamp);
crs.updateBytes(14, bytes);
crs.updateArray(15, aArray);
crs.updateRef(16, aRef);
crs.updateDouble(17, aDouble);
crs.insertRow();
crs.moveToCurrentRow();
}
示例12: commonRowSetTest0017
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0017(RowSet rs) throws Exception {
rs.setMaxFieldSize(0);
assertTrue(rs.getMaxFieldSize() == 0);
rs.setMaxFieldSize(100);
assertTrue(rs.getMaxFieldSize() == 100);
rs.setMaxFieldSize(50);
assertTrue(rs.getMaxFieldSize() == 50);
}
示例13: rowsetUsingCoffees
import javax.sql.RowSet; //導入依賴的package包/類
@DataProvider(name = "rowsetUsingCoffees")
protected Object[][] rowsetUsingCoffees() throws Exception {
RowSet rs = createCoffeesRowSet();
return new Object[][]{
{rs}
};
}
示例14: commonRowSetTest0022
import javax.sql.RowSet; //導入依賴的package包/類
@Test(dataProvider = "rowSetType")
public void commonRowSetTest0022(RowSet rs) throws Exception {
Map<String, Class<?>> map = new HashMap<>();
map.put("SUPERHERO", Class.forName("util.SuperHero"));
rs.setTypeMap(map);
assertTrue(rs.getTypeMap().equals(map));
}
示例15: initCoffeesMetaData
import javax.sql.RowSet; //導入依賴的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);
}