@Override
	public void addMedia(String name, String year, String genre,
			Object[] objects, int duration, int mediaType) throws SQLException {
		CallableStatement stMedia = null;
		CallableStatement stCreator = null;
		try {
			connection.setAutoCommit(false);
			//parameters: username, password, name, year, genre, duration, type
			String sql = "{call AddMedia(?, ?, ?, ?, ?, ?, ?, ?)}";

			stMedia = connection.prepareCall(sql);
			stMedia.setString(1, model.getUser());
			stMedia.setString(2, model.getPass());
			stMedia.setString(3, name);
			stMedia.setString(4, year);
			stMedia.setString(5, genre);
			stMedia.setInt(6, duration); 
			stMedia.setInt(7, mediaType);
			// returns the PK of the newly added media item, required when adding creators. 
			stMedia.registerOutParameter(8, java.sql.Types.INTEGER);
			stMedia.execute();

			// parameters: username, password, creator name, mediaId
			// the stored procedure will create a creator if not exists.
			sql = "{call AddCreator(?, ?, ?, ?)}";
			stCreator = connection.prepareCall(sql);
			for (int i = 0; i < objects.length; i++) {
				stCreator.setString(1, model.getUser());
				stCreator.setString(2, model.getPass());
				stCreator.setString(3, objects[i].toString());
				stCreator.setInt(4, stMedia.getInt(8));
				stCreator.execute();
			}			
			connection.commit();
		}
		catch (SQLException e)
		{
			connection.rollback();
			throw e;
		}
		 finally {
			connection.setAutoCommit(true);
			closeStatement(stMedia);
			closeStatement(stCreator);
		}
		// run last search query again, to display the added media.
		rebootDataSet();
	}