IoTDBPreparedStatement extends IoTDBStatement implements PreparedStatement { @Override public boolean execute() throws SQLException { return super.execute(createCompleteSql(sql, parameters)); } IoTDBPreparedStatement(IoTDBConnection connection, Iface client,
      Long sessionId, String sql,
      ZoneId zoneId); @Override void addBatch(); @Override void clearParameters(); @Override boolean execute(); @Override ResultSet executeQuery(); @Override int executeUpdate(); @Override ResultSetMetaData getMetaData(); @Override ParameterMetaData getParameterMetaData(); @Override void setArray(int parameterIndex, Array x); @Override void setAsciiStream(int parameterIndex, InputStream x); @Override void setAsciiStream(int parameterIndex, InputStream x, int length); @Override void setAsciiStream(int parameterIndex, InputStream x, long length); @Override void setBigDecimal(int parameterIndex, BigDecimal x); @Override void setBinaryStream(int parameterIndex, InputStream x); @Override void setBinaryStream(int parameterIndex, InputStream x, int length); @Override void setBinaryStream(int parameterIndex, InputStream x, long length); @Override void setBlob(int parameterIndex, Blob x); @Override void setBlob(int parameterIndex, InputStream inputStream); @Override void setBlob(int parameterIndex, InputStream inputStream, long length); @Override void setBoolean(int parameterIndex, boolean x); @Override void setByte(int parameterIndex, byte x); @Override void setBytes(int parameterIndex, byte[] x); @Override void setCharacterStream(int parameterIndex, Reader reader); @Override void setCharacterStream(int parameterIndex, Reader reader, int length); @Override void setCharacterStream(int parameterIndex, Reader reader, long length); @Override void setClob(int parameterIndex, Clob x); @Override void setClob(int parameterIndex, Reader reader); @Override void setClob(int parameterIndex, Reader reader, long length); @Override void setDate(int parameterIndex, Date x); @Override void setDate(int parameterIndex, Date x, Calendar cal); @Override void setDouble(int parameterIndex, double x); @Override void setFloat(int parameterIndex, float x); @Override void setInt(int parameterIndex, int x); @Override void setLong(int parameterIndex, long x); @Override void setNCharacterStream(int parameterIndex, Reader value); @Override void setNCharacterStream(int parameterIndex, Reader value, long length); @Override void setNClob(int parameterIndex, NClob value); @Override void setNClob(int parameterIndex, Reader reader); @Override void setNClob(int parameterIndex, Reader reader, long length); @Override void setNString(int parameterIndex, String value); @Override void setNull(int parameterIndex, int sqlType); @Override void setNull(int parameterIndex, int sqlType, String typeName); @Override void setObject(int parameterIndex, Object x); @Override void setObject(int parameterIndex, Object x, int targetSqlType); @Override void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength); @Override void setRef(int parameterIndex, Ref x); @Override void setRowId(int parameterIndex, RowId x); @Override void setSQLXML(int parameterIndex, SQLXML xmlObject); @Override void setShort(int parameterIndex, short x); @Override void setString(int parameterIndex, String x); @Override void setTime(int parameterIndex, Time x); @Override void setTime(int parameterIndex, Time x, Calendar cal); @Override void setTimestamp(int parameterIndex, Timestamp x); @Override void setTimestamp(int parameterIndex, Timestamp x, Calendar cal); @Override void setURL(int parameterIndex, URL x); @Override void setUnicodeStream(int parameterIndex, InputStream x, int length);  }
@SuppressWarnings("resource") @Test public void testNonParameterized() throws Exception { String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00"; IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql, zoneId); ps.execute(); ArgumentCaptor<TSExecuteStatementReq> argument = ArgumentCaptor .forClass(TSExecuteStatementReq.class); verify(client).executeStatement(argument.capture()); assertEquals( "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00", argument.getValue().getStatement()); }
@SuppressWarnings("resource") @Test(expected = SQLException.class) public void unsetArgument() throws SQLException { String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > ?"; IoTDBPreparedStatement ps = new IoTDBPreparedStatement(connection, client, sessionId, sql, zoneId); ps.execute(); }