Package com.mongodb

Examples of com.mongodb.MongoException$DuplicateKey


     * @throws MongoException in case no connection to Mongo exists.
     */
    public DBCollection getCollection() {
        Mongo mongo = m_mongoRef.get();
        if (mongo == null) {
            throw new MongoException("Not connected to MongoDB!");
        }
        DB db = mongo.getDB(m_dbName);
        return db.getCollection(m_collectionName);
    }
View Full Code Here


    final Role findExistingMember(String name)
    {
        Role result = m_roleProvider.getRole(name);
        if (result == null)
        {
            throw new MongoException("No such role: " + name);
        }
        return result;
    }
View Full Code Here

     * @param password the (optional) password to use.
     * @throws MongoException in case the connection or authentication failed.
     */
    private void connectToDB(MongoDB mongoDB, String userName, String password) throws MongoException {
        if (!mongoDB.connect(userName, password)) {
            throw new MongoException("Failed to connect to MongoDB! Authentication failed!");
        }

        DBCollection collection = mongoDB.getCollection();
        if (collection == null) {
            throw new MongoException("Failed to connect to MongoDB! No collection returned!");
        }

        collection.ensureIndex(new BasicDBObject(NAME, 1).append("unique", true));
    }
View Full Code Here

     * @throws MongoException in case no connection to MongoDB exists.
     */
    private DBCollection getCollection() {
        MongoDB mongoDB = m_mongoDbRef.get();
        if (mongoDB == null) {
            throw new MongoException("No connection to MongoDB?!");
        }
        return mongoDB.getCollection();
    }
View Full Code Here

        authenticate(username, password);
        if (auth) {
            mongo = new Mongo(url, port);
            db = mongo.getDB(dbName);
        }else{
            throw new MongoException("Access Denied for the given credentials");
        }
    }
View Full Code Here

     * @param password the (optional) password to use.
     * @throws MongoException in case the connection or authentication failed.
     */
    private void connectToDB(MongoDB mongoDB, String userName, String password) throws MongoException {
        if (!mongoDB.connect(userName, password)) {
            throw new MongoException("Failed to connect to MongoDB! Authentication failed!");
        }

        DBCollection collection = mongoDB.getCollection();
        if (collection == null) {
            throw new MongoException("Failed to connect to MongoDB! No collection returned!");
        }

        collection.ensureIndex(new BasicDBObject(NAME, 1).append("unique", true));
    }
View Full Code Here

     * @throws MongoException in case no connection to MongoDB exists.
     */
    private DBCollection getCollection() {
        MongoDB mongoDB = m_mongoDbRef.get();
        if (mongoDB == null) {
            throw new MongoException("No connection to MongoDB?!");
        }
        return mongoDB.getCollection();
    }
View Full Code Here

     * @throws MongoException in case the requested member was not found (or any other MongoDB exception).
     */
    final Role findExistingMember(String name) {
        Role result = m_roleProvider.getRole(name);
        if (result == null) {
            throw new MongoException("No such role: " + name);
        }
        return result;
    }
View Full Code Here

            objectMapper.writeValue(generator, object);
        } catch (JsonMappingException e) {
            throw new MongoJsonMappingException(e);
        } catch (IOException e) {
            // This shouldn't happen
            throw new MongoException(
                    "Unknown error occurred converting BSON to object", e);
        }
        return generator.getDBObject();
    }
View Full Code Here

                objectMapper.writerWithView(view).writeValue(generator, object);
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                // This shouldn't happen
                throw new MongoException(
                        "Unknown error occurred converting BSON to object", e);
            }
            return generator.getDBObject();
        }
    }
View Full Code Here

TOP

Related Classes of com.mongodb.MongoException$DuplicateKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.