}
}
public int createTemplate(DataSets dataSets) throws DBException, UnknownHostException, DAOCreationException {
DeviceDAO deviceDAO;
DataCollectorDAO collectorDAO;
PreparedStatement statement;
ResultSet results;
int sessionID;
try {
deviceDAO = DAOFactory.getDeviceDAO();
deviceDAO.create(dataSets.getDevice());
deviceDAO.closeConnection();
statement = connection.prepareStatement(CREATE_TEMPLATE, Statement.RETURN_GENERATED_KEYS);
statement.setInt(1, dataSets.getDataType().id);
//statement.setString(2, dataSets.getCollectorName());
statement.setInt(2, DataCollectorDAOType.getDAOID(dataSets.getCollector().getClass()));
statement.setInt(3, 0);
statement.setString(4, dataSets.getDevice().getName());
statement.setLong(5, dataSets.getPollInterval());
statement.setString(6, dataSets.getPortString());
statement.setLong(7, 0);
statement.setString(8, dataSets.getTitle());
statement.setLong(9, dataSets.getDirection());
statement.setInt(10, dataSets.isStoring() ? 1 : 0);
statement.executeUpdate();
results = statement.getGeneratedKeys();
results.next();
sessionID = results.getInt(1);
results.close();
statement.close();
// TODO - store collector here
collectorDAO = DAOFactory.getDataCollectorDAO(connection, dataSets.getCollector());
collectorDAO.create(sessionID, dataSets.getCollector());
collectorDAO.closeConnection();
//dataSets.getCollector().store(sessionID);
logger.debug("Adding new session with ID " + sessionID);
return sessionID;
} catch (SQLException e) {