/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package de.uhilger.radiozentrale.api; import de.uhilger.baselink.GenericRecord; import de.uhilger.baselink.PersistenceManager; import java.util.List; /** * */ public abstract class DbApi extends Api { public static final String SQL_GET_NEXT_KEY = "getNextKey"; public static final String SQL_INCREMENT_KEY = "incrementKey"; protected int getNextId(PersistenceManager db, String key) { int nextKey = -1; List> list = db.select(getSql(SQL_GET_NEXT_KEY), GenericRecord.WITHOUT_BLOBS, key); if(list != null && list.size() > 1) { nextKey = Integer.parseInt(list.get(1).get(0)); // erster Datensatz ist Ueberschrift if(nextKey > -1) { db.execute(getSql(SQL_INCREMENT_KEY), nextKey+1, key, nextKey); } } return nextKey; } }