Campbell Ritchie wrote:Welcome to the Ranch
![]()
Thank you for using code tags, but you didn't quite have them right: the [code=java] part goes before the code and the [/code] part after; I corrected it by moving the second part, so doesn't it look better. Also, you appear to have asked the same question twice, so I have deleted the other post.
Don't use com.mongodb as a package name; as you will see from the Java™ Tutorials, that name belongs to somebody else. Try database or something as a package name.
Let's see if we can't find a MongoDB tutorial. Let's try here. It doesn't appear that you have a connectivity problem, but something to do with types which the compiler doesn't like. About ⅓ way down that tutorial, it gives you this line of code:-Compare that with your line 21, which appears to be the location of the error (thank you for supplying a good copy of the error message.) It seems, as the compiler error message says, that you have something which returns a DB reference, so you appear to have declared the database object with the wrong type. Do you know where the Java® API documentation about MongoDB is? That might be very helpful. Does the documentation appear when you hover your mouse over “getDB” on Eclipse?
In which case they are entitled to use the package name themselves. Remember the naming conventions next timeHarsh Saxena wrote:. . . . I am actually on the Mongo university course "MongoDb for Java developers" and the package name is as directed in the video namely "com.mongodb.
That is useful information, but you should be able to get the API documentation for the method by hovering your mouse over the method name. Even more useful information if you can find it.Here's is what I can see when I hover my mouse over getDB(). . .
No, you cannot cast to incompatible types. You will (I think) have to declare the database as type DB.I have tried casting to MongoDb but that has not helped. . . .
That is more useful information for us; please also tell them on that site that you have posted here, to avoid duplication of effort.I have posted this problem on the mongodb unversity dicussion . . .
Don't be so pessimistic about themI guess as I am running a week behind no one will look at this query.
Campbell Ritchie wrote:
In which case they are entitled to use the package name themselves. Remember the naming conventions next timeHarsh Saxena wrote:. . . . I am actually on the Mongo university course "MongoDb for Java developers" and the package name is as directed in the video namely "com.mongodb.
That is useful information, but you should be able to get the API documentation for the method by hovering your mouse over the method name. Even more useful information if you can find it.Here's is what I can see when I hover my mouse over getDB(). . .
No, you cannot cast to incompatible types. You will (I think) have to declare the database as type DB.I have tried casting to MongoDb but that has not helped. . . .
That is more useful information for us; please also tell them on that site that you have posted here, to avoid duplication of effort.I have posted this problem on the mongodb unversity dicussion . . .
Don't be so pessimistic about themI guess as I am running a week behind no one will look at this query.
![]()
Quick! Before anybody notices! Cover it up with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|