java获取某个oracle序列的当前最大值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yuliqi0429/article/details/78952559

废话不多说直接上代码:

 public int findLastValueBySQName(String SQName) {
		Connection connection = DBUtil.getConnection();
		StringBuffer buffer = new StringBuffer();
		buffer.append(
				"select last_number from user_sequences where sequence_name='")
				.append(SQName.toUpperCase()).append("'");
		try {
			PreparedStatement statement = connection.prepareStatement(buffer.toString());
			ResultSet resultSet = statement.executeQuery();
			if (resultSet.next()) {
				return resultSet.getInt(1);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return 0;
	}


猜你喜欢

转载自blog.csdn.net/yuliqi0429/article/details/78952559