All pastes #516190 Raw Edit

Anonymous

public text v1 · immutable
#516190 ·published 2007-05-28 16:09 UTC
rendered paste body
/**
	 * Returns the next id of the current table. The tabe is the default table
	 * When a certain mapper is iniitalised.
	 * 
	 * @return	int	next table id
	 */
	protected int nextId() {
		int id = 0;
		String sql = "SHOW TABLE STATUS LIKE '" + getTable() + "'";
		
		try {
			ResultSet rs = select(sql);
			
			
			if(! rs.next()) return 0;
			id = rs.getInt("Auto_increment");			
			rs.close();	
			System.out.println("next id: " + id);
			
			return id;
		} catch(SQLException e) {
			e.printStackTrace();
			
			return 0;
		}
	}