Search in sources :

Example 1 with RowId

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

the class SWCallableStatementTest method testSetParam.

@Test
public void testSetParam() throws SQLException, MalformedURLException {
    CallableStatement callableStatement = multiHostConnection.prepareCall("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 = ?");
    callableStatement.clearParameters();
    callableStatement.setAsciiStream(1, inputStream);
    callableStatement.setAsciiStream(2, inputStream, 10);
    callableStatement.setAsciiStream(3, inputStream, 1000000L);
    callableStatement.setCharacterStream(4, reader);
    callableStatement.setCharacterStream(4, reader, 10);
    callableStatement.setCharacterStream(5, reader, 10L);
    callableStatement.setShort(6, (short) 12);
    callableStatement.setInt(7, 1);
    callableStatement.setString(8, "test");
    callableStatement.setBoolean(9, true);
    callableStatement.setLong(10, 100L);
    callableStatement.setDouble(11, 12.0);
    callableStatement.setFloat(12, 12.0f);
    callableStatement.setByte(13, (byte) 1);
    callableStatement.setBytes(14, bytesParam);
    callableStatement.setDate(15, new Date(System.currentTimeMillis()));
    callableStatement.setNull(16, 1);
    callableStatement.setNull(17, 1, "test");
    callableStatement.setBigDecimal(18, new BigDecimal(10000));
    callableStatement.setBlob(19, inputStream);
    callableStatement.setBlob(20, inputStream, 1000000L);
    callableStatement.setClob(21, clob);
    callableStatement.setClob(22, reader);
    callableStatement.setClob(23, reader, 100L);
    callableStatement.setNString(24, "test");
    callableStatement.setNCharacterStream(25, reader);
    callableStatement.setNCharacterStream(26, reader, 1);
    callableStatement.setNClob(27, nClob);
    callableStatement.setNClob(28, reader, 1);
    callableStatement.setObject(29, new Object());
    callableStatement.setObject(30, new Object(), 1);
    callableStatement.setObject(31, new Object(), 1, 1);
    callableStatement.setRef(32, ref);
    callableStatement.setRowId(33, rowId);
    callableStatement.setSQLXML(34, sqlxml);
    callableStatement.setTime(35, new Time(System.currentTimeMillis()));
    callableStatement.setTimestamp(36, new Timestamp(System.currentTimeMillis()));
    callableStatement.setTimestamp(37, new Timestamp(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.setURL(38, new URL("http", "127.0.0.1", "test"));
    callableStatement.setBinaryStream(39, inputStream);
    callableStatement.setBinaryStream(40, inputStream, 1);
    callableStatement.setBinaryStream(41, inputStream, 1L);
    callableStatement.setNClob(42, reader);
    callableStatement.setTime(43, new Time(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.setArray(45, array);
    callableStatement.setBlob(46, blob);
    callableStatement.setDate(47, new Date(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.getCharacterStream(4);
    callableStatement.getCharacterStream("d");
    callableStatement.getShort(6);
    callableStatement.getShort("g");
    callableStatement.getInt(7);
    callableStatement.getInt("h");
    callableStatement.getString(8);
    callableStatement.getString("i");
    callableStatement.getBoolean(9);
    callableStatement.getBoolean("j");
    callableStatement.getLong(10);
    callableStatement.getLong("k");
    callableStatement.getDouble(11);
    callableStatement.getDouble("l");
    callableStatement.getFloat(12);
    callableStatement.getFloat("m");
    callableStatement.getByte(13);
    callableStatement.getByte("n");
    callableStatement.getBytes(14);
    callableStatement.getBytes("o");
    callableStatement.getDate(15);
    callableStatement.getDate("p");
    callableStatement.getBigDecimal(18);
    callableStatement.getBigDecimal("s");
    callableStatement.getBlob(19);
    callableStatement.getBlob("t");
    callableStatement.getClob(21);
    callableStatement.getClob(21);
    callableStatement.getClob("u");
    callableStatement.getNString(24);
    callableStatement.getNString("y");
    callableStatement.getNCharacterStream(25);
    callableStatement.getNCharacterStream("z");
    callableStatement.getNClob(27);
    callableStatement.getNClob("a1");
    callableStatement.getRef(32);
    callableStatement.getRef("a2");
    callableStatement.getRowId(33);
    callableStatement.getRowId("a7");
    callableStatement.getSQLXML(34);
    callableStatement.getSQLXML("a8");
    callableStatement.getTime(35);
    callableStatement.getTime("a9");
    callableStatement.getTimestamp(36);
    callableStatement.getTimestamp("b1");
    callableStatement.getURL(38);
    callableStatement.getURL("b3");
    callableStatement.getArray(45);
    callableStatement.getArray("c4");
    callableStatement.getDate(15);
    callableStatement.getDate("p");
    callableStatement.getDate(15, Calendar.getInstance());
    callableStatement.getDate("p", Calendar.getInstance());
    callableStatement.getTime("a9");
    callableStatement.getTime("a9", Calendar.getInstance());
    callableStatement.getTime(43);
    callableStatement.getTime(43, Calendar.getInstance());
    callableStatement.getTimestamp("p", Calendar.getInstance());
    callableStatement.getTimestamp(36, Calendar.getInstance());
    callableStatement.getObject(29);
    callableStatement.getObject(29, new HashMap<String, Class<?>>());
    callableStatement.getObject("a4");
    callableStatement.getObject("a4", new HashMap<String, Class<?>>());
    callableStatement.getBigDecimal(18, 1);
    callableStatement.wasNull();
    callableStatement.setAsciiStream("a", inputStream);
    callableStatement.setAsciiStream("b", inputStream, 10);
    callableStatement.setAsciiStream("c", inputStream, 1000000L);
    callableStatement.setCharacterStream("d", reader);
    callableStatement.setCharacterStream("e", reader, 10);
    callableStatement.setCharacterStream("f", reader, 10L);
    callableStatement.setShort("g", (short) 12);
    callableStatement.setInt("h", 1);
    callableStatement.setString("i", "test");
    callableStatement.setBoolean("j", true);
    callableStatement.setLong("k", 100L);
    callableStatement.setDouble("l", 12.0);
    callableStatement.setFloat("m", 12.0f);
    callableStatement.setByte("n", (byte) 1);
    callableStatement.setBytes("o", bytesParam);
    callableStatement.setDate("p", new Date(System.currentTimeMillis()));
    callableStatement.setNull("q", 1);
    callableStatement.setNull("r", 1, "test");
    callableStatement.setBigDecimal("s", new BigDecimal(10000));
    callableStatement.setBlob("t", inputStream);
    callableStatement.setBlob("u", inputStream, 1000000L);
    callableStatement.setClob("v", clob);
    callableStatement.setClob("w", reader);
    callableStatement.setClob("x", reader, 100L);
    callableStatement.setNString("y", "test");
    callableStatement.setNCharacterStream("z", reader);
    callableStatement.setNCharacterStream("a1", reader, 1);
    callableStatement.setNClob("a2", nClob);
    callableStatement.setNClob("a3", reader, 1);
    callableStatement.setObject("a4", new Object());
    callableStatement.setObject("a5", new Object(), 1);
    callableStatement.setObject("a6", new Object(), 1, 1);
    callableStatement.setRowId("a7", rowId);
    callableStatement.setSQLXML("a8", sqlxml);
    callableStatement.setTime("a9", new Time(System.currentTimeMillis()));
    callableStatement.setTimestamp("b1", new Timestamp(System.currentTimeMillis()));
    callableStatement.setTimestamp("b2", new Timestamp(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.setURL("b3", new URL("http", "127.0.0.1", "test"));
    callableStatement.setBinaryStream("b4", inputStream);
    callableStatement.setBinaryStream("b5", inputStream, 1);
    callableStatement.setBinaryStream("b6", inputStream, 1L);
    callableStatement.setNClob("b7", reader);
    callableStatement.setTime("b8", new Time(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.setBlob("c1", blob);
    callableStatement.setDate("c2", new Date(System.currentTimeMillis()), Calendar.getInstance());
    callableStatement.registerOutParameter("c4", 1);
    callableStatement.registerOutParameter("c5", 1, 1);
    callableStatement.registerOutParameter("c6", 1, "test");
    callableStatement.registerOutParameter(48, 1);
    callableStatement.registerOutParameter(49, 1, 1);
    callableStatement.registerOutParameter(50, 1, "test");
    ResultSet resultSet = callableStatement.executeQuery();
    callableStatement.close();
    verify(mysqlCallableStatement, times(1)).clearParameters();
    verify(mysqlCallableStatement, times(1)).executeQuery();
    verify(mysqlCallableStatement, times(1)).close();
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setShort(anyInt(), anyShort());
    verify(mysqlCallableStatement, times(1)).setInt(anyInt(), anyInt());
    verify(mysqlCallableStatement, times(1)).setString(anyInt(), anyString());
    verify(mysqlCallableStatement, times(1)).setBoolean(anyInt(), anyBoolean());
    verify(mysqlCallableStatement, times(1)).setLong(anyInt(), anyLong());
    verify(mysqlCallableStatement, times(1)).setDouble(anyInt(), anyDouble());
    verify(mysqlCallableStatement, times(1)).setFloat(anyInt(), anyFloat());
    verify(mysqlCallableStatement, times(1)).setByte(anyInt(), anyByte());
    verify(mysqlCallableStatement, times(1)).setBytes(14, bytesParam);
    verify(mysqlCallableStatement, times(1)).setDate(anyInt(), any(Date.class));
    verify(mysqlCallableStatement, times(1)).setNull(anyInt(), anyInt());
    verify(mysqlCallableStatement, times(1)).setNull(anyInt(), anyInt(), anyString());
    verify(mysqlCallableStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Clob.class));
    verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setNString(anyInt(), anyString());
    verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setNClob(27, nClob);
    verify(mysqlCallableStatement, times(1)).setNClob(28, reader, 1);
    verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject());
    verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt());
    verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt());
    verify(mysqlCallableStatement, times(1)).setRef(anyInt(), any(Ref.class));
    verify(mysqlCallableStatement, times(1)).setRowId(anyInt(), any(RowId.class));
    verify(mysqlCallableStatement, times(1)).setSQLXML(anyInt(), any(SQLXML.class));
    verify(mysqlCallableStatement, times(1)).setTime(anyInt(), any(Time.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setURL(anyInt(), any(URL.class));
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setNClob(42, reader);
    verify(mysqlCallableStatement, times(1)).setTime(anyInt(), any(Time.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setArray(anyInt(), any(Array.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(Blob.class));
    verify(mysqlCallableStatement, times(1)).setDate(anyInt(), any(Date.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).clearParameters();
    verify(mysqlCallableStatement, times(1)).executeQuery();
    verify(mysqlCallableStatement, times(1)).close();
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setShort(anyString(), anyShort());
    verify(mysqlCallableStatement, times(1)).setInt(anyString(), anyInt());
    verify(mysqlCallableStatement, times(1)).setString(anyString(), anyString());
    verify(mysqlCallableStatement, times(1)).setBoolean(anyString(), anyBoolean());
    verify(mysqlCallableStatement, times(1)).setLong(anyString(), anyLong());
    verify(mysqlCallableStatement, times(1)).setDouble(anyString(), anyDouble());
    verify(mysqlCallableStatement, times(1)).setFloat(anyString(), anyFloat());
    verify(mysqlCallableStatement, times(1)).setByte(anyString(), anyByte());
    verify(mysqlCallableStatement, times(1)).setBytes(14, bytesParam);
    verify(mysqlCallableStatement, times(1)).setDate(anyString(), any(Date.class));
    verify(mysqlCallableStatement, times(1)).setNull(anyString(), anyInt());
    verify(mysqlCallableStatement, times(1)).setNull(anyString(), anyInt(), anyString());
    verify(mysqlCallableStatement, times(1)).setBigDecimal(anyString(), any(BigDecimal.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Clob.class));
    verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setNString(anyString(), anyString());
    verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyString(), any(Reader.class));
    verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyString(), any(Reader.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setNClob(27, nClob);
    verify(mysqlCallableStatement, times(1)).setNClob(28, reader, 1);
    verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject());
    verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject(), anyInt());
    verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject(), anyInt(), anyInt());
    verify(mysqlCallableStatement, times(1)).setRowId(anyString(), any(RowId.class));
    verify(mysqlCallableStatement, times(1)).setSQLXML(anyString(), any(SQLXML.class));
    verify(mysqlCallableStatement, times(1)).setTime(anyString(), any(Time.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setURL(anyString(), any(URL.class));
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class));
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class), anyInt());
    verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class), anyLong());
    verify(mysqlCallableStatement, times(1)).setNClob(42, reader);
    verify(mysqlCallableStatement, times(1)).setTime(anyString(), any(Time.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class));
    verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(Blob.class));
    verify(mysqlCallableStatement, times(1)).setDate(anyString(), 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) Time(java.sql.Time) Matchers.anyString(org.mockito.Matchers.anyString) 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) CallableStatement(java.sql.CallableStatement) ResultSet(java.sql.ResultSet) NClob(java.sql.NClob) Clob(java.sql.Clob) Test(org.junit.Test)

Example 2 with RowId

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

the class CommonRowSetTests method commonRowSetTest0147.

/*
     * This method is currently not implemented in BaseRowSet and will
     * throw a SQLFeatureNotSupportedException
     */
@Test(dataProvider = "rowSetType", expectedExceptions = SQLFeatureNotSupportedException.class)
public void commonRowSetTest0147(RowSet rs) throws Exception {
    RowId aRowid = null;
    rs.setRowId("one", aRowid);
}
Also used : RowId(java.sql.RowId) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 3 with RowId

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

the class TestFBRowIdField method getObject_RowId.

@Test
@Override
public void getObject_RowId() throws SQLException {
    final byte[] bytes = getRandomBytes();
    toReturnValueExpectations(bytes);
    RowId rowId = field.getObject(RowId.class);
    assertArrayEquals(bytes, rowId.getBytes());
}
Also used : RowId(java.sql.RowId) FBRowId(org.firebirdsql.jdbc.FBRowId) Test(org.junit.Test)

Example 4 with RowId

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

the class TestFBRowIdField method getRowIdNonNull.

@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 5 with RowId

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

the class TestFBRowIdField method setObject_RowId.

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

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