public static boolean putCollection(Collection collection) {
	if (connection != null) {
	    PreparedStatement updateCollection = null;
	    PreparedStatement insertCollection = null;
	    Statement selectRowid = null;
	    ResultSet selectRowidRS = null;
	    try {
		if (collection.getId() > 0) {
		    updateCollection = connection.prepareStatement("UPDATE " + TBLCOLLECTION
			    + " SET profileId=?, parentID=?, name=?, description=? WHERE id=?;");
		    updateCollection.setObject(1, collection.getProfileId(), java.sql.Types.INTEGER);
		    updateCollection.setObject(2, collection.getParentId(), java.sql.Types.INTEGER);
		    updateCollection.setObject(3, collection.getName(), java.sql.Types.VARCHAR);
		    updateCollection.setObject(4, collection.getDescription(), java.sql.Types.VARCHAR);
		    updateCollection.setObject(5, collection.getId(), java.sql.Types.INTEGER);
		    updateCollection.executeUpdate();
		    updateCollection.close();
		} else {
		    insertCollection = connection.prepareStatement("INSERT INTO " + TBLCOLLECTION
			    + "(id,profileId,parentId,name,description) VALUES(?,?,?,?,?);");
		    insertCollection.setNull(1, java.sql.Types.INTEGER);
		    insertCollection.setObject(2, collection.getProfileId(), java.sql.Types.INTEGER);
		    insertCollection.setObject(3, collection.getParentId(), java.sql.Types.INTEGER);
		    insertCollection.setObject(4, collection.getName(), java.sql.Types.VARCHAR);
		    insertCollection.setObject(5, collection.getDescription(), java.sql.Types.VARCHAR);
		    insertCollection.executeUpdate();
		    insertCollection.close();

		    selectRowid = connection.createStatement();
		    selectRowidRS = selectRowid.executeQuery("SELECT last_insert_rowid();");
		    if (selectRowidRS.next()) {
			collection.setId(selectRowidRS.getInt(1));
		    }
		    selectRowidRS.close();
		    selectRowid.close();
		}
		return true;
	    } catch (SQLException e) {
		e.printStackTrace();
	    } finally {
		try {
		    if (selectRowidRS != null)
			selectRowidRS.close();
		    if (selectRowid != null)
			selectRowid.close();
		    if (insertCollection != null)
			insertCollection.close();
		    if (updateCollection != null)
			updateCollection.close();
		} catch (SQLException e) {
		    e.printStackTrace();
		}
	    }
	}
	return false;
    }