Search in sources :

Example 11 with RowId

use of java.sql.RowId in project jaybird by FirebirdSQL.

the class TestFBBinaryField method setRowIdNonNull.

@Test
@Override
public void setRowIdNonNull() throws SQLException {
    final byte[] bytes = getRandomBytes();
    final RowId rowId = new FBRowId(bytes);
    setValueExpectations(bytes);
    field.setRowId(rowId);
}
Also used : RowId(java.sql.RowId) FBRowId(org.firebirdsql.jdbc.FBRowId) FBRowId(org.firebirdsql.jdbc.FBRowId) Test(org.junit.Test)

Example 12 with RowId

use of java.sql.RowId in project jaybird by FirebirdSQL.

the class TestFBBinaryField method getRowIdNonNull.

// Binary fields supports setting RowId, because Firebird doesn't support detection of row id parameters
@Test
@Override
public void getRowIdNonNull() throws SQLException {
    final byte[] bytes = getRandomBytes();
    toReturnValueExpectations(bytes);
    RowId rowId = field.getRowId();
    assertArrayEquals(bytes, rowId.getBytes());
}
Also used : RowId(java.sql.RowId) FBRowId(org.firebirdsql.jdbc.FBRowId) Test(org.junit.Test)

Example 13 with RowId

use of java.sql.RowId in project derby by apache.

the class PreparedStatementTest method testSetRowId.

// --------------------------------------------------------------------------
// BEGIN THE TEST OF THE METHODS THAT THROW AN UNIMPLEMENTED EXCEPTION IN
// THIS CLASS
/**
 * Tests the setRowId method of the PreparedStatement interface
 *
 * @throws SQLException upon any failure that occurs in the
 *         call to the method.
 */
public void testSetRowId() throws SQLException {
    try {
        RowId rowid = null;
        ps.setRowId(0, rowid);
        fail("setRowId should not be implemented");
    } catch (SQLFeatureNotSupportedException sqlfne) {
    // Do Nothing, This happens as expected
    }
}
Also used : RowId(java.sql.RowId) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException)

Example 14 with RowId

use of java.sql.RowId in project incubator-skywalking by apache.

the class SwPreparedStatementTest method testSetParam.

@Test
public void testSetParam() throws SQLException, MalformedURLException {
    PreparedStatement preparedStatement = multiHostConnection.prepareStatement("SELECT * FROM test WHERE a = ? or b = ? or c=? or d = ? or e = ?" + " or e = ? or f = ? or g = ? or h = ? or i = ? or j = ? or k = ? or l = ? or m = ?  or n = ? or o = ? or p = ? " + " or r = ?  or s = ? or t = ?  or u = ?  or v = ?  or w = ?  or x = ?  or y = ? or z = ? or a1 = ? or a2 = ? or a3 = ?" + " or a4 = ? or a5 = ? or a6 = ?  or a7 = ?  or a8 = ?  or a9 = ? or b1 = ? or b2 = ? or b3 = ? or b4 = ? or b5 = ?" + " or b6 = ? or b7 = ? or b8  = ? or b9 = ? or c1 = ?  or c2 = ? or c3 = ?");
    preparedStatement.clearParameters();
    preparedStatement.setAsciiStream(1, inputStream);
    preparedStatement.setAsciiStream(2, inputStream, 10);
    preparedStatement.setAsciiStream(3, inputStream, 1000000L);
    preparedStatement.setCharacterStream(4, reader);
    preparedStatement.setCharacterStream(4, reader, 10);
    preparedStatement.setCharacterStream(5, reader, 10L);
    preparedStatement.setShort(6, (short) 12);
    preparedStatement.setInt(7, 1);
    preparedStatement.setString(8, "test");
    preparedStatement.setBoolean(9, true);
    preparedStatement.setLong(10, 100L);
    preparedStatement.setDouble(11, 12.0);
    preparedStatement.setFloat(12, 12.0f);
    preparedStatement.setByte(13, (byte) 1);
    preparedStatement.setBytes(14, bytesParam);
    preparedStatement.setDate(15, new Date(System.currentTimeMillis()));
    preparedStatement.setNull(16, 1);
    preparedStatement.setNull(17, 1, "test");
    preparedStatement.setBigDecimal(18, new BigDecimal(10000));
    preparedStatement.setBlob(19, inputStream);
    preparedStatement.setBlob(20, inputStream, 1000000L);
    preparedStatement.setClob(21, clob);
    preparedStatement.setClob(22, reader);
    preparedStatement.setClob(23, reader, 100L);
    preparedStatement.setNString(24, "test");
    preparedStatement.setNCharacterStream(25, reader);
    preparedStatement.setNCharacterStream(26, reader, 1);
    preparedStatement.setNClob(27, nClob);
    preparedStatement.setNClob(28, reader, 1);
    preparedStatement.setObject(29, new Object());
    preparedStatement.setObject(30, new Object(), 1);
    preparedStatement.setObject(31, new Object(), 1, 1);
    preparedStatement.setRef(32, ref);
    preparedStatement.setRowId(33, rowId);
    preparedStatement.setSQLXML(34, sqlxml);
    preparedStatement.setTime(35, new Time(System.currentTimeMillis()));
    preparedStatement.setTimestamp(36, new Timestamp(System.currentTimeMillis()));
    preparedStatement.setTimestamp(37, new Timestamp(System.currentTimeMillis()), Calendar.getInstance());
    preparedStatement.setURL(38, new URL("http", "127.0.0.1", "test"));
    preparedStatement.setBinaryStream(39, inputStream);
    preparedStatement.setBinaryStream(40, inputStream, 1);
    preparedStatement.setBinaryStream(41, inputStream, 1L);
    preparedStatement.setNClob(42, reader);
    preparedStatement.setTime(43, new Time(System.currentTimeMillis()), Calendar.getInstance());
    preparedStatement.setArray(45, array);
    preparedStatement.setBlob(46, blob);
    preparedStatement.setDate(47, new Date(System.currentTimeMillis()), Calendar.getInstance());
    ResultSet resultSet = preparedStatement.executeQuery();
    preparedStatement.close();
    verify(mysqlPreparedStatement, times(1)).clearParameters();
    verify(mysqlPreparedStatement, times(1)).executeQuery();
    verify(mysqlPreparedStatement, times(1)).close();
    verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class));
    verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyInt());
    verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class));
    verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyInt());
    verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyLong());
    verify(mysqlPreparedStatement, times(1)).setShort(anyInt(), anyShort());
    verify(mysqlPreparedStatement, times(1)).setInt(anyInt(), anyInt());
    verify(mysqlPreparedStatement, times(1)).setString(anyInt(), anyString());
    verify(mysqlPreparedStatement, times(1)).setBoolean(anyInt(), anyBoolean());
    verify(mysqlPreparedStatement, times(1)).setLong(anyInt(), anyLong());
    verify(mysqlPreparedStatement, times(1)).setDouble(anyInt(), anyDouble());
    verify(mysqlPreparedStatement, times(1)).setFloat(anyInt(), anyFloat());
    verify(mysqlPreparedStatement, times(1)).setByte(anyInt(), anyByte());
    verify(mysqlPreparedStatement, times(1)).setBytes(14, bytesParam);
    verify(mysqlPreparedStatement, times(1)).setDate(anyInt(), any(Date.class));
    verify(mysqlPreparedStatement, times(1)).setNull(anyInt(), anyInt());
    verify(mysqlPreparedStatement, times(1)).setNull(anyInt(), anyInt(), anyString());
    verify(mysqlPreparedStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class));
    verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class));
    verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Clob.class));
    verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Reader.class));
    verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Reader.class), anyInt());
    verify(mysqlPreparedStatement, times(1)).setNString(anyInt(), anyString());
    verify(mysqlPreparedStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class));
    verify(mysqlPreparedStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class), anyInt());
    verify(mysqlPreparedStatement, times(1)).setNClob(27, nClob);
    verify(mysqlPreparedStatement, times(1)).setNClob(28, reader, 1);
    verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject());
    verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt());
    verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt());
    verify(mysqlPreparedStatement, times(1)).setRef(anyInt(), any(Ref.class));
    verify(mysqlPreparedStatement, times(1)).setRowId(anyInt(), any(RowId.class));
    verify(mysqlPreparedStatement, times(1)).setSQLXML(anyInt(), any(SQLXML.class));
    verify(mysqlPreparedStatement, times(1)).setTime(anyInt(), any(Time.class));
    verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class));
    verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlPreparedStatement, times(1)).setURL(anyInt(), any(URL.class));
    verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class));
    verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyInt());
    verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlPreparedStatement, times(1)).setNClob(42, reader);
    verify(mysqlPreparedStatement, times(1)).setTime(anyInt(), any(Time.class), any(Calendar.class));
    verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlPreparedStatement, times(1)).setArray(anyInt(), any(Array.class));
    verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(Blob.class));
    verify(mysqlPreparedStatement, times(1)).setDate(anyInt(), any(Date.class), any(Calendar.class));
}
Also used : RowId(java.sql.RowId) Blob(java.sql.Blob) InputStream(java.io.InputStream) Calendar(java.util.Calendar) Reader(java.io.Reader) PreparedStatement(java.sql.PreparedStatement) Time(java.sql.Time) Timestamp(java.sql.Timestamp) Date(java.sql.Date) BigDecimal(java.math.BigDecimal) URL(java.net.URL) Array(java.sql.Array) Ref(java.sql.Ref) SQLXML(java.sql.SQLXML) ResultSet(java.sql.ResultSet) NClob(java.sql.NClob) Clob(java.sql.Clob) Test(org.junit.Test)

Example 15 with RowId

use of java.sql.RowId in project druid by alibaba.

the class ResultSetProxyImpl method getRowId.

@Override
public RowId getRowId(int columnIndex) throws SQLException {
    FilterChainImpl chain = createChain();
    RowId value = chain.resultSet_getRowId(this, columnIndex);
    recycleFilterChain(chain);
    return value;
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) RowId(java.sql.RowId)

Aggregations

RowId (java.sql.RowId)16 Test (org.junit.Test)12 FBRowId (org.firebirdsql.jdbc.FBRowId)10 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)2 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 BigDecimal (java.math.BigDecimal)2 URL (java.net.URL)2 Array (java.sql.Array)2 Blob (java.sql.Blob)2 Clob (java.sql.Clob)2 Date (java.sql.Date)2 NClob (java.sql.NClob)2 Ref (java.sql.Ref)2 ResultSet (java.sql.ResultSet)2 SQLXML (java.sql.SQLXML)2 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 Calendar (java.util.Calendar)2 CallableStatement (java.sql.CallableStatement)1