[JAVA-993] Providing a method to return version of the currently connected mongo instance Created: 09/Oct/13 Updated: 27/Nov/16 Resolved: 27/Nov/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.11.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Fatih Güçlü Akkaya | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Currently from java driver version of the connected Mongo instance can be learn via following code snippet. DB db = new MongoClient("127.0.0.1").getDB("test"); However similar to CLI DB class can have a method like db.getVersion() to get version of the mongo instance. |
| Comments |
| Comment by Jeffrey Yemin [ 27/Nov/16 ] |
|
See the Cluster Monitoring section of http://mongodb.github.io/mongo-java-driver/3.3/driver/reference/management/monitoring/ for an alternative solution. |
| Comment by Jeffrey Yemin [ 10/Oct/13 ] |
|
Thanks for sharing the use case. |
| Comment by Fatih Güçlü Akkaya [ 10/Oct/13 ] |
|
I come across an issue that in need to add an array of items under an array field. For mongo instance lower than 2.4 in need to use $pushAll. (Current mongo version is 2.2.2) However i do not my code to be affect by mongo version change, so for safety i need to get the version in order to do following if (version < 2.4) Currently i do not know another use case, where i needed this kind of switch, but it would be also nice to use it for logging. |
| Comment by Jeffrey Yemin [ 09/Oct/13 ] |
|
I'm curious what you want to do different in your code based on the version of Mongo? Or do you just want to log it? |