Search in sources :

Example 1 with Ref

use of java.sql.Ref in project robovm by robovm.

the class OldPreparedStatementTest method testSetRef.

public void testSetRef() {
    ResultSet res = null;
    PreparedStatement ps = null;
    Ref mock = new MockRef();
    try {
        String neverExecutedQuery = "select TBlob from type;";
        ps = conn.prepareStatement(neverExecutedQuery);
        ps.setRef(1, mock);
        fail("Exception expected not supported");
    } catch (SQLException e) {
    //ok
    }
}
Also used : Ref(java.sql.Ref) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 2 with Ref

use of java.sql.Ref in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method createDataTypesRows.

/*
     * Add rows to DATAYPES table
     */
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();
}
Also used : Time(java.sql.Time) LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) Timestamp(java.sql.Timestamp) BigDecimal(java.math.BigDecimal) Date(java.sql.Date) LocalDate(java.time.LocalDate) StubArray(util.StubArray) Array(java.sql.Array) StubRef(util.StubRef) StubRef(util.StubRef) SerialRef(javax.sql.rowset.serial.SerialRef) Ref(java.sql.Ref) SerialRef(javax.sql.rowset.serial.SerialRef) StubArray(util.StubArray)

Example 3 with Ref

use of java.sql.Ref in project jdk8u_jdk by JetBrains.

the class BaseRowSetTests method testAdvancedParameters.

/*
     * DataProvider used to set advanced parameters for types that are supported
     */
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {
    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);
    ;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());
    return new Object[][] { { 1, bytes }, { 2, is }, { 3, aRef }, { 4, aArray }, { 5, aBlob }, { 6, aClob }, { 7, is }, { 8, is }, { 9, rdr } };
}
Also used : SerialArray(javax.sql.rowset.serial.SerialArray) StubBlob(util.StubBlob) SerialBlob(javax.sql.rowset.serial.SerialBlob) Blob(java.sql.Blob) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) StringReader(java.io.StringReader) SerialBlob(javax.sql.rowset.serial.SerialBlob) StubClob(util.StubClob) StubBlob(util.StubBlob) SerialClob(javax.sql.rowset.serial.SerialClob) StubRef(util.StubRef) StubArray(util.StubArray) Array(java.sql.Array) SerialArray(javax.sql.rowset.serial.SerialArray) StubRef(util.StubRef) SerialRef(javax.sql.rowset.serial.SerialRef) Ref(java.sql.Ref) StringBufferInputStream(java.io.StringBufferInputStream) StringReader(java.io.StringReader) StubBaseRowSet(util.StubBaseRowSet) SerialRef(javax.sql.rowset.serial.SerialRef) Clob(java.sql.Clob) StubClob(util.StubClob) SerialClob(javax.sql.rowset.serial.SerialClob) StubArray(util.StubArray) DataProvider(org.testng.annotations.DataProvider)

Example 4 with Ref

use of java.sql.Ref in project jdk8u_jdk by JetBrains.

the class SQLInputImplTests method test09.

/*
     * Validate a Ref can be read
     */
@Test(enabled = true)
public void test09() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    Object[] values = { ref };
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Ref ref2 = sqli.readRef();
    assertTrue(ref.getObject().equals(ref2.getObject()));
    assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
Also used : StubRef(util.StubRef) StubRef(util.StubRef) Ref(java.sql.Ref) SQLInputImpl(javax.sql.rowset.serial.SQLInputImpl) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 5 with Ref

use of java.sql.Ref in project jdk8u_jdk by JetBrains.

the class SQLOutputImplTests method test07.

/*
     * Validate a Ref can be written and returned
     */
@Test(enabled = true)
public void test07() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    outImpl.writeRef(ref);
    SerialRef sr = (SerialRef) results.get(0);
    assertTrue(hero.equals(sr.getObject()));
}
Also used : StubRef(util.StubRef) StubRef(util.StubRef) SerialRef(javax.sql.rowset.serial.SerialRef) Ref(java.sql.Ref) SerialRef(javax.sql.rowset.serial.SerialRef) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

Ref (java.sql.Ref)9 StubRef (util.StubRef)4 SQLException (java.sql.SQLException)3 SerialRef (javax.sql.rowset.serial.SerialRef)3 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)2 Array (java.sql.Array)2 ResultSet (java.sql.ResultSet)2 Test (org.testng.annotations.Test)2 BaseTest (util.BaseTest)2 StubArray (util.StubArray)2 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 StringBufferInputStream (java.io.StringBufferInputStream)1 StringReader (java.io.StringReader)1 BigDecimal (java.math.BigDecimal)1 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 Date (java.sql.Date)1 PreparedStatement (java.sql.PreparedStatement)1 Time (java.sql.Time)1