APISonar


java.sql.JDBCType.DATE

> java > sql > JDBCType > DATE
java APIs sql APIs JDBCType APIs DATE APIs

Example 1
public void writeWithDateFieldWithDateTypeFromMetaData() throws Exception {
    Date fieldValue = new Date();
    Object expectedValueWritten = new java.sql.Date(fieldValue.getTime());
    JDBCType dataType = JDBCType.DATE;
    when(tableMetaDataView.getColumnDataType(fieldName)).thenReturn(dataType);
    when(value.getField(fieldName)).thenReturn(fieldValue);

    when(statement.executeUpdate()).thenReturn(1);
    Object createKey = "createKey";
    handler.write(region, Operation.CREATE, createKey, value);

    verify(statement).setObject(1, expectedValueWritten);
    verify(statement).setObject(2, createKey);
    verify(statement).close();
  }
Example 2
public void executeFunctionThrowsGivenExistingPdxTypeWithWrongNumberOfFields()
      throws Exception {
    Set<String> columnNames = new LinkedHashSet<>(Arrays.asList("col1"));
    when(tableMetaDataView.getColumnNames()).thenReturn(columnNames);
    when(tableMetaDataView.isColumnNullable("col1")).thenReturn(false);
    when(tableMetaDataView.getColumnDataType("col1")).thenReturn(JDBCType.DATE);
    when(pdxType.getFieldCount()).thenReturn(2);

    Throwable throwable = catchThrowable(() -> function.executeFunction(context));

    assertThat(throwable).isInstanceOf(JdbcConnectorException.class)
        .hasMessage(
            "The table and pdx class must have the same number of columns/fields. But the table has 1 columns and the pdx class has 2 fields.");
  }
Example 3
boolean passDataAsString(int colNum) {
        JDBCType jt = getColumn(colNum).getJdbctype();
        return (JDBCType.CHAR == jt || JDBCType.VARCHAR == jt || JDBCType.NCHAR == jt || JDBCType.NVARCHAR == jt
                || JDBCType.TIMESTAMP == jt || JDBCType.DATE == jt || JDBCType.TIME == jt || JDBCType.LONGVARCHAR == jt
                || JDBCType.LONGNVARCHAR == jt);
    }