Is there any way to execute a mongo query without the java driver, and get the raw string response in java?
What protocol is used by the mongo server <---> mongo client?
Thanks!
If it's only about querying (not insert, update, or remove operations), you can use simple REST API included in mongod process.
It is generally used for monitoring, alert scripts, and administrative tasks
Examples:
To get the contents of a collection:
http://127.0.0.1:28017/databaseName/collectionName/
To add a limit:
http://127.0.0.1:28017/databaseName/collectionName/?limit=-10
To skip:
http://127.0.0.1:28017/databaseName/collectionName/?skip=5
To query for {a : 1}:
http://127.0.0.1:28017/databaseName/collectionName/?filter_a=1
As per mongo's documentation:
This API is disabled by default, as it could provide unauthenticated access to data. Use --rest on the command line to enable, but be aware of security implications
Check details to enable this.
The Mongo Java Driver uses the "MongoDB Wire protocol". It is a socket oriented BSON communication protocol.
You can see/examine it for example in Wireshark when you connect to a MongoDB database that does not use SSL/TLS (filter for TCP port 27017).