Questions tagged [mongodb-java]

MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Java language bindings and drivers for MongoDB.

Java Language Center

Java Driver

Basics

Specific Topics and How-To

Reference

1045 questions
0
votes
1 answer

issue with $inc operator & java driver

I'm getting this error: Document field names can't start with '$' (Bad Key: '$inc') with this code: private static void countryInc(String user_id, String country, BasicDBObject doc, DBCollection dBcollection, Integer count ) throws IOException { …
adam
  • 940
  • 5
  • 13
  • 30
0
votes
1 answer

How to configure Eclipselink nosql JPA implementation with mongodb nosql database?

I want to use JPA to create an entity class that can be used with the persistence context to access my db2 nosql database. The problem is the @NoSql annotation is not being found. As per…
user2316667
  • 5,444
  • 13
  • 49
  • 71
0
votes
1 answer

Check if value exists in mongodb

I'm trying to write a method that will check if a user_id is in the DB and then operate on the user_id.The portion of code that I'm stuck on is this: DBObject query = new BasicDBObject(user_id,new BasicDBObject("$regex", true)); DBCursor result =…
adam
  • 940
  • 5
  • 13
  • 30
0
votes
0 answers

Mongodb for Java(ADT), how to create connection?

This is the code that I was trying to error, and gave me an error. try { MongoClient mongoClient = new MongoClient("localhost", 27017); DB db = mongoClient.getDB("mydatabase"); DBCollection table =…
Adrian
  • 836
  • 7
  • 20
  • 44
0
votes
1 answer

MongoDB set multiple fields with update

I am trying to set multiple fields with an update in MongoDB using Java DBObject nameQuery = new BasicDBObject(); nameQuery.put(DBUser.LAST_SEEN_NAME_FIELD, player.getName()); nameQuery.put(DBUser.LAST_SEEN_NAME_LOWER_FIELD,…
PHPDEV
  • 383
  • 1
  • 4
  • 12
0
votes
2 answers

Duplicate Key error while using MongoDB insert using java mongo db driver

I get this error while trying to insert data from a JSON file. Only one item is added to the database. 11000 E11000 duplicate key error index: awdb.mycollection.$_id_ dup > key: { : ObjectId('53954d897aadbe032a33cd68') } > >…
ben_joseph
  • 1,660
  • 1
  • 19
  • 24
0
votes
1 answer

Tell if a BasicMongoDBObject is valid from the .toString()?

I'd like to confirm that a parser I wrote is working correctly. It takes a JavaScript mongodb command that could be run from the terminal and converts it to a Java object for the MongoDB/Java drivers. Is the following .toString() result valid? {…
Kyte
  • 834
  • 2
  • 12
  • 27
0
votes
1 answer

Java MongoClient cannot connect to primary

I have a replica set setup with 1 primary (mongo1.test.com), 1 secondary(mongo2.test.com) and 1 arbiter(mongo3.test.com). When I use MongoClient to connect to them and print out the ReplicaSetStatus, it shows that mongo1.test.com is unconnected with…
Chaos907
  • 3
  • 1
  • 1
  • 3
0
votes
1 answer

MongoDB equivelant to SQL "NOT LIKE" query

I have the following SQL statement SELECT Currency, TransTime, AuthTime FROM MONIES WHERE Currency not like 'USD%'; If the SQL statement were simply a "LIKE" query, it would yield the following MongoDB statement db.MONIES.find({ "Currency":…
Kyte
  • 834
  • 2
  • 12
  • 27
0
votes
2 answers

Trimming double quotes of a string which is saved as a value in mongodb java driver

I have something like this written using mongodb driver for java: doc = new BasicDBObject("Physicalentity", "Pressure"). append("Sensor", "Tinkerforge"). append("Unit", "Lux"). append("loc", Location). append("value", pressure). append("time",…
0
votes
2 answers

display subdocuments with mongodb and jsp?

Mongodb and JSP : my code : DBCursor curseur = table.find(); while (curseur.hasNext()) { DBObject ligne = curseur.next(); out.println(ligne.get("_id")); out.println(ligne.get("joueur")); out.println(ligne.get("equipes")); …
0
votes
1 answer

Convert DDObject from a bson document using java

As I required to import the collection of mongodb from a bson document. How do I achieve that? and I'm using Java. Is there any API for this? Guide me through this. Thanks in advance
Varun Kumar
  • 1,015
  • 2
  • 9
  • 17
0
votes
0 answers

Mongodb geospatial query for finding buses/commutes around two cities

I'm new to mongodb and amazed by the fact that it handles geospatial coordinates and indexing/searching beautifully. However I have a scenario where any help would be appreciated. I am developing an application that let's user find buses…
0
votes
2 answers

find by key in a map in grails domain mongodb

I am using mongodb plugin with grails (latest versions). I have a domain similar to: class User { HashMap baseAddr static mapWith = "mongo" } The User data in DB is like: { "_id" : NumberLong(1), "baseAddr" : { …
akash777.sharma
  • 702
  • 10
  • 30
0
votes
1 answer

Dynamic Dropdown menu in JSP with MONGODB

I am trying to implement a simple dynamic dropdown menu in JSP.I am using MONGODB.Here is my code.But I am getting