I'm trying to follow this post to create a "contains" query in Java. The problem is it's giving me an error.
At the moment i have the following code:
MongoClient mongoClient = null;
DBCursor cursor = null;
mongoClient = new MongoClient( "localhost" , 27017 );
DB db = mongoClient.getDB("bd-films");
DBCollection coll = db.getCollection("films");
DBObject query = new BasicDBObject({"title" : {$regex : "name"}});
cursor = coll.find(query);
The error it gives me is in the 'query' line:
Syntax error on token ""title"", invalid Label
Syntax error, insert ";" to complete Statement
Syntax error on token ")", delete this token
I use the cursor for inserting it into a JTable.
Driver: mongo-java-driver-3.4.2
Thanks in advance.