废话不多说直接上代码:
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;
}