It looks like you're connecting and authenticating to one database (heroku_app1234) but then switching to another (myDB). You're getting the error not authorized for insert on myDb.myCollection
as a result.
When you grab the database to pass into the Jongo()
constructor you should be sure to grab the same one as used in the URI. It looks like you're using Java. If so, this tweak to your code may work for you:
MongoClientUri uri = new MongoClientUri("mongodb://heroku_app1234:random_password@ds029017.mongolab.com:29017/heroku_app1234");
MongoClient client = new MongoClient(uri);
Jongo jongo = new Jongo(client.getDB(uri.getDatabase()));
MongoCollection collection = jongo.getCollection("myCollection");
collection.save(someBean);
client.close();
We have some basic connection examples in our Language Center, including one for Java that you can feel free to pull from.
// Standard URI format: mongodb://[dbuser:dbpassword@]host:port/dbname
MongoClientURI uri = new MongoClientURI("mongodb://user:pass@host:port/db");
MongoClient client = new MongoClient(uri);
DB db = client.getDB(uri.getDatabase());