java tutorial example, DBObject.put(String, int) ?

556 views
Skip to first unread message

Stoph

unread,
Jul 17, 2009, 1:48:16 AM7/17/09
to mongodb-user
Hello everyone!

I am testing out MongoDB, and I noticed on the Java examples page
there is code like this:

BasicDBObject info = new BasicDBObject();
info.put("x", 203);

I do not believe that DBObject.put() supports int for the 2nd
argument. I have no problems using Integer.valueOf(int) in the 2nd
argument.

Anyway, thanks for making this great database,

Chris

Eliot Horowitz

unread,
Jul 17, 2009, 6:59:20 AM7/17/09
to mongod...@googlegroups.com
I just verified that this works for me.
What error are you getting when you try it?

Stoph

unread,
Jul 17, 2009, 12:14:01 PM7/17/09
to mongodb-user
Compilation error:

/my_path/MainMethod.java:[24,11] cannot find symbol
symbol : method put(java.lang.String,int)
location: class com.mongodb.BasicDBObject

This is using mongo-0.6.jar from http://github.com/mongodb/mongo-java-driver/downloads

Am I possibly using the wrong driver? I have looked at the code on
github and it only provides a signature for:

put(String, Object)

On Jul 17, 6:59 am, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> I just verified that this works for me.
> What error are you getting when you try it?
>

Eliot Horowitz

unread,
Jul 17, 2009, 12:16:39 PM7/17/09
to mongod...@googlegroups.com
What version of java?
That's the correct jar...

Stoph

unread,
Jul 18, 2009, 2:24:41 PM7/18/09
to mongodb-user
I'm using Java 6 obtained from the Ubuntu package manager. I'll let
you know if I can figure out why I seem to be the only one
experiencing this so far.

On Jul 17, 12:16 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> What version of java?
> That's the correct jar...
>
> On Fri, Jul 17, 2009 at 12:14 PM, Stoph<stoph...@gmail.com> wrote:
>
> > Compilation error:
>
> > /my_path/MainMethod.java:[24,11] cannot find symbol
> > symbol  : method put(java.lang.String,int)
> > location: class com.mongodb.BasicDBObject
>
> > This is using mongo-0.6.jar fromhttp://github.com/mongodb/mongo-java-driver/downloads

Stoph

unread,
Jul 19, 2009, 8:58:00 PM7/19/09
to mongodb-user
I cannot reproduce this problem on my PC running Windows XP.

Eliot Horowitz

unread,
Jul 20, 2009, 4:20:02 PM7/20/09
to mongod...@googlegroups.com
Can you do a java -version? Is is possible you're using a weird java version?

Elcio Nakashima

unread,
Jul 20, 2009, 6:06:07 PM7/20/09
to mongodb-user
Stoph

That problem you are reporting has to be something wrong with your
JDK. If your JDK is really following Java 6 standards, it should work,
the primitive int type should be automatically boxed to an Integer
object. Your problem definitely is not the mongodb driver.


On Jul 20, 5:20 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> Can you do a java -version?   Is is possible you're using a weird java version?
>
Reply all
Reply to author
Forward
0 new messages