public Date getDate(int columnIndex) throws SQLException { return getDate(columnIndex, null); }
public Date getDate(int columnIndex) throws SQLException { return getDate(columnIndex, null); }
public Date getDate(String columnName) throws SQLException { // find the columnIndex for the given column name. return getDate(findColumn(columnName)); }
public Date getDate(String columnName) throws SQLException { // find the columnIndex for the given column name. return getDate(findColumn(columnName)); }
/** * Get the Date value for the given column. * * @param columnName * . The name of the column whose value needs to be fetched. * @param Calender * object used to get the date value. * @return value of the column as an int. * @throws SQLException * unable to obtain date value for the given column. */ public Date getDate(String columnName, Calendar cal) throws SQLException { // find the columnIndex for the given column name. return getDate(findColumn(columnName), cal); }
/** * Get the Date value for the given column. * * @param columnName * . The name of the column whose value needs to be fetched. * @param Calender * object used to get the date value. * @return value of the column as an int. * @throws SQLException * unable to obtain date value for the given column. */ public Date getDate(String columnName, Calendar cal) throws SQLException { // find the columnIndex for the given column name. return getDate(findColumn(columnName), cal); }
@Test public void testGetters() throws SQLException{ TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00")); //$NON-NLS-1$ ResultsMessage message = exampleMessage(new List[] { Arrays.asList(1, TimestampUtil.createTime(0, 0, 0), TimestampUtil.createDate(1, 1, 1), TimestampUtil.createTimestamp(1, 1, 1, 1, 1, 1, 1), "<root/>") }, //$NON-NLS-1$ new String[] { "int", "time", "date", "timestamp", "sqlxml" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.TIME, DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.STRING }); TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$ ResultSetImpl rs = new ResultSetImpl(message, statement); assertTrue(rs.next()); assertEquals(Boolean.TRUE.booleanValue(), rs.getBoolean(1)); assertEquals(1, rs.getShort(1)); assertEquals(1, rs.getInt(1)); assertEquals(1l, rs.getLong(1)); assertEquals(1f, rs.getFloat(1), 0); assertEquals(1d, rs.getDouble(1), 0); assertEquals("1", rs.getString(1)); //$NON-NLS-1$ assertEquals(Integer.valueOf(1), rs.getObject(1)); //the mock statement is in GMT-6 the server results are from GMT-5, so we expect them to display the same assertEquals(TimestampUtil.createTime(0, 0, 0), rs.getTime(2)); assertEquals(TimestampUtil.createDate(1, 1, 1), rs.getDate(3)); assertEquals(TimestampUtil.createTimestamp(1, 1, 1, 1, 1, 1, 1), rs.getTimestamp(4)); assertEquals("<root/>", rs.getSQLXML(5).getString()); //$NON-NLS-1$ try { rs.getSQLXML(1); } catch (SQLException e) { assertEquals("Unable to transform the column value 1 to a SQLXML.", e.getMessage()); //$NON-NLS-1$ } assertFalse(rs.next()); TimestampWithTimezone.resetCalendar(null); }