当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getTime方法代码示例

本文整理汇总了Java中java.sql.ResultSet.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getTime方法的具体用法?Java ResultSet.getTime怎么用?Java ResultSet.getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getTime方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResult

import java.sql.ResultSet; //导入方法依赖的package包/类
public Object getResult(ResultSet rs, String columnName) throws SQLException {

            Object sqlTime = rs.getTime(columnName);
            if (rs.wasNull()) {
                return null;
            }
            else {
                return sqlTime;
            }
        }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:11,代码来源:DAOFactory.java

示例2: getObject

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Get a column value from a {@link ResultSet} for the specified name.
 *
 * @param resultSet The result set
 * @param name The property name
 * @return The value
 * @throws SQLException if an error occurs
 */
protected Object getObject(final ResultSet resultSet, final String name) throws SQLException {

    final DynaProperty property = getDynaProperty(name);
    if (property == null) {
        throw new IllegalArgumentException("Invalid name '" + name + "'");
    }
    final String columnName = getColumnName(name);
    final Class<?> type = property.getType();

    // java.sql.Date
    if (type.equals(Date.class)) {
        return resultSet.getDate(columnName);
    }

    // java.sql.Timestamp
    if (type.equals(Timestamp.class)) {
        return resultSet.getTimestamp(columnName);
    }

    // java.sql.Time
    if (type.equals(Time.class)) {
        return resultSet.getTime(columnName);
    }

    return resultSet.getObject(columnName);
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:35,代码来源:JDBCDynaClass.java

示例3: getMeetingById

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Meeting getMeetingById(int meetingId) throws SQLException {
	Meeting m = null;
	PreparedStatement stm = c.prepareStatement(SQLStatements.selectMeetingById);
	stm.setInt(1, meetingId);
	ResultSet rs = stm.executeQuery();
	if (rs.next()) {

		java.sql.Date SDate = rs.getDate(DataContract.MeetingTable.COL_DATE);

		m = new Meeting(rs.getInt(DataContract.MeetingTable.COL_ACTIVITYID),
				rs.getInt(DataContract.MeetingTable.COL_PAIRID), rs.getInt(DataContract.MeetingTable.COL_MENTORID),
				rs.getInt(DataContract.MeetingTable.COL_MENTEEID), rs.getString(DataContract.MeetingTable.COL_NOTE),
				meetingStatus.valueOf(rs.getInt(DataContract.MeetingTable.COL_STATUS)),
				rs.getString(DataContract.MeetingTable.COL_MENTEEREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTEEPRIVREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORPRIVREPORT),
				meetingType.getByValue(rs.getInt(DataContract.MeetingTable.COL_MEETINGTYPE)),
				rs.getString(DataContract.MeetingTable.COL_SUBJECT),
				rs.getString(DataContract.MeetingTable.COL_LOCATION), SDate.getTime(),
				rs.getTime(DataContract.MeetingTable.COL_STARTINGTIME),
				rs.getTime(DataContract.MeetingTable.COL_ENDINGTIME),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTORCOMPLETE),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTEECOMPLETE));

	}
	rs.close();
	stm.close();

	return m;
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:33,代码来源:DataAccess.java

示例4: getMeetingsByPairId

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public ArrayList<Meeting> getMeetingsByPairId(int pairId) throws SQLException {
	ArrayList<Meeting> m = new ArrayList<Meeting>();
	Meeting meeting = null;

	PreparedStatement stm = c.prepareStatement(SQLStatements.selectMeetingByPairId);
	stm.setInt(1, pairId);
	ResultSet rs = stm.executeQuery();

	while (rs.next()) {
		java.sql.Date SDate = rs.getDate(DataContract.MeetingTable.COL_DATE);

		meeting = new Meeting(rs.getInt(DataContract.MeetingTable.COL_ACTIVITYID),
				rs.getInt(DataContract.MeetingTable.COL_PAIRID), rs.getInt(DataContract.MeetingTable.COL_MENTORID),
				rs.getInt(DataContract.MeetingTable.COL_MENTEEID), rs.getString(DataContract.MeetingTable.COL_NOTE),
				meetingStatus.valueOf(rs.getInt(DataContract.MeetingTable.COL_STATUS)),
				rs.getString(DataContract.MeetingTable.COL_MENTEEREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTEEPRIVREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORPRIVREPORT),
				meetingType.getByValue(rs.getInt(DataContract.MeetingTable.COL_MEETINGTYPE)),
				rs.getString(DataContract.MeetingTable.COL_SUBJECT),
				rs.getString(DataContract.MeetingTable.COL_LOCATION), SDate.getTime(),
				rs.getTime(DataContract.MeetingTable.COL_STARTINGTIME),
				rs.getTime(DataContract.MeetingTable.COL_ENDINGTIME),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTORCOMPLETE),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTEECOMPLETE));
		m.add(meeting);
	}
	rs.close();
	stm.close();

	return m;
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:35,代码来源:DataAccess.java

示例5: getNullableResult

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Date getNullableResult(ResultSet rs, String columnName) throws SQLException {
	java.sql.Time sqlTime = rs.getTime(columnName);
	if (sqlTime != null) {
		return new Date(sqlTime.getTime());
	}
	return null;
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:9,代码来源:TimeOnlyTypeHandler.java

示例6: testGetTime

import java.sql.ResultSet; //导入方法依赖的package包/类
public void testGetTime(ResultSet resultSet, Calendar calendar) throws SQLException {
  try {
    resultSet.getTime(ordinal, calendar);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:9,代码来源:AvaticaResultSetConversionsTest.java

示例7: testBasicDefaultTimeSupport

import java.sql.ResultSet; //导入方法依赖的package包/类
public void testBasicDefaultTimeSupport() throws Throwable {

        final String INSERT_TIME =
            "insert into time_test(time_test) values (?)";

        // See OracleTests class why we need to select tablename.*
        final String SELECT_TIME =
            "select time_test.* from time_test where time_test = ?";
        final String DELETE_TIME = "delete from time_test where time_test = ?";
        java.sql.Time     insertTime;
        Connection        connection = super.newConnection();
        PreparedStatement insertStatement;
        int               iUpdateCount = 0;

        insertTime      = new java.sql.Time(3600000);
        insertStatement = connection.prepareStatement(INSERT_TIME);

        insertStatement.setTime(1, insertTime);

        iUpdateCount = insertStatement.executeUpdate();

        insertStatement.close();
        Assert.assertEquals(
            "Exactly one record with time data shoud have been inserted.",
            iUpdateCount, 1);

        // Now select it back to be sure it is there
        PreparedStatement selectStatement = null;
        PreparedStatement deleteStatement = null;
        ResultSet         results         = null;
        java.sql.Time     retrievedTime;
        int               iDeletedCount = 0;
        java.sql.Time     selectTime;

        selectStatement = connection.prepareStatement(SELECT_TIME);
        selectTime      = new java.sql.Time(3600000);

        selectStatement.setTime(1, selectTime);

        results = selectStatement.executeQuery();

        // Get the date from the database
        Assert.assertTrue("The inserted time is not in the database.",
                          results.next());

        retrievedTime = results.getTime(1);

        //
        deleteStatement = connection.prepareStatement(DELETE_TIME);

        deleteStatement.setTime(1, insertTime);

        iDeletedCount = deleteStatement.executeUpdate();

        Assert.assertEquals(
            "Exactly one record with time data shoud have been deleted.",
            iDeletedCount, 1);

        // And now test the date
        Assert.assertNotNull(
            "The inserted time shouldn't be retrieved as null from the database",
            retrievedTime);

        // Ignore milliseconds when comparing dates
        String  selectString    = selectTime.toString();
        String  retrievedString = retrievedTime.toString();
        boolean result          = retrievedString.equals(selectString);

        Assert.assertTrue(
            "The time retrieved from database "
            + DateFormat.getDateTimeInstance().format(retrievedTime)
            + " is not the same as the inserted one "
            + DateFormat.getDateTimeInstance().format(insertTime), result);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:75,代码来源:TestDateTime.java

示例8: getUserMeetings

import java.sql.ResultSet; //导入方法依赖的package包/类
@SuppressWarnings("resource") // got warning about stm in case 3 not being closed
@Override
public ArrayList<Meeting> getUserMeetings(int id) throws SQLException {
	ArrayList<Meeting> meeting = new ArrayList<Meeting>();
	Meeting meet = null;
	PreparedStatement stm = c.prepareStatement(SQLStatements.selectUserById);
	stm.setInt(1, id);
	ResultSet rs = stm.executeQuery();

	if (rs.next()) {
		int type = rs.getInt(DataContract.UsersTable.COL_TYPE);
		switch (type) {
		case 2:// Mentor
			stm = c.prepareStatement(SQLStatements.selectMeetingsByMentorId);
			break;
		case 3:// Mentee
			stm = c.prepareStatement(SQLStatements.selectMeetingsByMenteeId);
			break;
		default:
			// TODO: LOG ERROR
			rs.close();
			stm.close();

			return null;
		}
	}

	stm.setInt(1, id);
	rs = stm.executeQuery();
	while (rs.next()) {
		java.sql.Date SDate = rs.getDate(DataContract.MeetingTable.COL_DATE);
		meet = new Meeting(rs.getInt(DataContract.MeetingTable.COL_ACTIVITYID),
				rs.getInt(DataContract.MeetingTable.COL_PAIRID), rs.getInt(DataContract.MeetingTable.COL_MENTORID),
				rs.getInt(DataContract.MeetingTable.COL_MENTEEID), rs.getString(DataContract.MeetingTable.COL_NOTE),
				meetingStatus.valueOf(rs.getInt(DataContract.MeetingTable.COL_STATUS)),
				rs.getString(DataContract.MeetingTable.COL_MENTEEREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTEEPRIVREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORPRIVREPORT),
				meetingType.getByValue(rs.getInt(DataContract.MeetingTable.COL_MEETINGTYPE)),
				rs.getString(DataContract.MeetingTable.COL_SUBJECT),
				rs.getString(DataContract.MeetingTable.COL_LOCATION), SDate.getTime(),
				rs.getTime(DataContract.MeetingTable.COL_STARTINGTIME),
				rs.getTime(DataContract.MeetingTable.COL_ENDINGTIME),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTORCOMPLETE),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTEECOMPLETE));
		meeting.add(meet);

	}
	rs.close();
	stm.close();

	return meeting;
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:55,代码来源:DataAccess.java

示例9: getMeetingByStatus

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public ArrayList<Meeting> getMeetingByStatus(int userId, meetingStatus status, int count, int page)
		throws SQLException {
	ArrayList<Meeting> m = new ArrayList<Meeting>();
	PreparedStatement stm = null;

	userType type = getUser(userId).getType();

	if (type == userType.MENTEE) {
		stm = c.prepareStatement(SQLStatements.getMeetingsByMentee);
	} else if (type == userType.MENTOR) {
		stm = c.prepareStatement(SQLStatements.getMeetingsByMentor);
	} else {
		return null;
	}

	stm.setInt(1, userId);
	stm.setInt(2, status.ordinal());
	stm.setInt(3, (page - 1) * (count));
	stm.setInt(4, count);
	ResultSet rs = stm.executeQuery();
	m = new ArrayList<Meeting>();
	while (rs.next()) {
		java.sql.Date SDate = rs.getDate(DataContract.MeetingTable.COL_DATE);

		Meeting meet = new Meeting(rs.getInt(DataContract.MeetingTable.COL_ACTIVITYID),
				rs.getInt(DataContract.MeetingTable.COL_PAIRID), rs.getInt(DataContract.MeetingTable.COL_MENTORID),
				rs.getInt(DataContract.MeetingTable.COL_MENTEEID), rs.getString(DataContract.MeetingTable.COL_NOTE),
				meetingStatus.valueOf(rs.getInt(DataContract.MeetingTable.COL_STATUS)),
				rs.getString(DataContract.MeetingTable.COL_MENTEEREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTEEPRIVREPORT),
				rs.getString(DataContract.MeetingTable.COL_MENTORPRIVREPORT),
				meetingType.getByValue(rs.getInt(DataContract.MeetingTable.COL_MEETINGTYPE)),
				rs.getString(DataContract.MeetingTable.COL_SUBJECT),
				rs.getString(DataContract.MeetingTable.COL_LOCATION), SDate.getTime(),
				rs.getTime(DataContract.MeetingTable.COL_STARTINGTIME),
				rs.getTime(DataContract.MeetingTable.COL_ENDINGTIME),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTORCOMPLETE),
				rs.getBoolean(DataContract.MeetingTable.COL_MENTEECOMPLETE));
		m.add(meet);
	}

	rs.close();
	stm.close();

	return m;
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:49,代码来源:DataAccess.java

示例10: readTime

import java.sql.ResultSet; //导入方法依赖的package包/类
public static Time readTime(int colNum, ResultSet r) throws SQLException {
  return r.getTime(colNum);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:4,代码来源:JdbcWritableBridge.java

示例11: getNullableResult

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Time getNullableResult(ResultSet rs, String columnName) throws SQLException {
	return rs.getTime(columnName);
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:5,代码来源:SqlTimeTypeHandler.java

示例12: getValue

import java.sql.ResultSet; //导入方法依赖的package包/类
private static Object getValue(ResultSet resultSet, int type, int j,
    Calendar calendar) throws SQLException {
  switch (type) {
  case Types.BIGINT:
    final long aLong = resultSet.getLong(j + 1);
    return aLong == 0 && resultSet.wasNull() ? null : aLong;
  case Types.INTEGER:
    final int anInt = resultSet.getInt(j + 1);
    return anInt == 0 && resultSet.wasNull() ? null : anInt;
  case Types.SMALLINT:
    final short aShort = resultSet.getShort(j + 1);
    return aShort == 0 && resultSet.wasNull() ? null : aShort;
  case Types.TINYINT:
    final byte aByte = resultSet.getByte(j + 1);
    return aByte == 0 && resultSet.wasNull() ? null : aByte;
  case Types.DOUBLE:
  case Types.FLOAT:
    final double aDouble = resultSet.getDouble(j + 1);
    return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
  case Types.REAL:
    final float aFloat = resultSet.getFloat(j + 1);
    return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
  case Types.DATE:
    final Date aDate = resultSet.getDate(j + 1, calendar);
    return aDate == null
        ? null
        : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIME:
    final Time aTime = resultSet.getTime(j + 1, calendar);
    return aTime == null
        ? null
        : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIMESTAMP:
    final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
    return aTimestamp == null ? null : aTimestamp.getTime();
  case Types.ARRAY:
    final Array array = resultSet.getArray(j + 1);
    if (null == array) {
      return null;
    }
    try {
      // Recursively extracts an Array using its ResultSet-representation
      return extractUsingResultSet(array, calendar);
    } catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
      // Not every database might implement Array.getResultSet(). This call
      // assumes a non-nested array (depends on the db if that's a valid assumption)
      return extractUsingArray(array, calendar);
    }
  case Types.STRUCT:
    Struct struct = resultSet.getObject(j + 1, Struct.class);
    Object[] attrs = struct.getAttributes();
    List<Object> list = new ArrayList<>(attrs.length);
    for (Object o : attrs) {
      list.add(o);
    }
    return list;
  default:
    return resultSet.getObject(j + 1);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:61,代码来源:JdbcResultSet.java

示例13: jdbcGet

import java.sql.ResultSet; //导入方法依赖的package包/类
/** Returns the value of a column of this type from a result set. */
public Object jdbcGet(ResultSet resultSet, int i) throws SQLException {
  switch (this) {
  case PRIMITIVE_BOOLEAN:
    return resultSet.getBoolean(i);
  case PRIMITIVE_BYTE:
    return resultSet.getByte(i);
  case PRIMITIVE_SHORT:
    return resultSet.getShort(i);
  case PRIMITIVE_INT:
    return resultSet.getInt(i);
  case PRIMITIVE_LONG:
    return resultSet.getLong(i);
  case PRIMITIVE_FLOAT:
    return resultSet.getFloat(i);
  case PRIMITIVE_DOUBLE:
    return resultSet.getDouble(i);
  case BOOLEAN:
    final boolean aBoolean = resultSet.getBoolean(i);
    return resultSet.wasNull() ? null : aBoolean;
  case BYTE:
    final byte aByte = resultSet.getByte(i);
    return resultSet.wasNull() ? null : aByte;
  case SHORT:
    final short aShort = resultSet.getShort(i);
    return resultSet.wasNull() ? null : aShort;
  case INTEGER:
    final int anInt = resultSet.getInt(i);
    return resultSet.wasNull() ? null : anInt;
  case LONG:
    final long aLong = resultSet.getLong(i);
    return resultSet.wasNull() ? null : aLong;
  case FLOAT:
    final float aFloat = resultSet.getFloat(i);
    return resultSet.wasNull() ? null : aFloat;
  case DOUBLE:
    final double aDouble = resultSet.getDouble(i);
    return resultSet.wasNull() ? null : aDouble;
  case JAVA_SQL_DATE:
    return resultSet.getDate(i);
  case JAVA_SQL_TIME:
    return resultSet.getTime(i);
  case JAVA_SQL_TIMESTAMP:
    return resultSet.getTimestamp(i);
  case ARRAY:
    return resultSet.getArray(i);
  case STRUCT:
    return resultSet.getObject(i, Struct.class);
  default:
    return resultSet.getObject(i);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:53,代码来源:ColumnMetaData.java

示例14: getValue

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <V> V getValue(ResultSet rs, int colIndex) throws SQLException {
    return (V)rs.getTime(colIndex);
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:6,代码来源:SQLExtractor.java


注:本文中的java.sql.ResultSet.getTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。