java獲取某個oracle序列的當前最大值
阿新 • • 發佈:2019-01-11
廢話不多說直接上程式碼:
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; }