Closed nirby82 closed 8 years ago
Hi!
You have to set the required parameters:
Moreover, in your special case you have to set credential parameter.
So, your builder should be as follows:
val builder = MongodbConfigBuilder(Map(Host -> List("localhost:27017"), Database -> "databaseName", Collection -> "collectionName", Credentials -> "user,database,password"))
val readConfig = builder.build()
if you have a big collection and you know the collection schema, it is better to use it, else, add a small SamplingRatio to the builder.
For small collections this doesn't matter.
You can see complete examples in our documentation.
thanks
seems like a connection was made because i am no longer getting a connection error.
now I am receiving this error:
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to scala.collection.TraversableLike
at com.stratio.provider.mongodb.partitioner.MongodbPartitioner.
Which version of our project are you using?
0.9.0
Sorry but i can't reproduce your error, credentials are working for me.
Let me know more about your code.
Are you using master branch, right?
This is a simple example with java, and works for me:
public class Mongo {
public static void main(String[] args) {
JavaSparkContext sc = new JavaSparkContext("local[2]", "test mongo java");
SQLContext sqlContext = new org.apache.spark.sql.SQLContext(sc);
Map options = new HashMap();
options.put("host", "localhost:27017");
options.put("database", "highschoolCredentials");
options.put("collection", "students");
options.put("credentials", "user,highschoolCredentials,password");
DataFrame df = sqlContext.read().format("com.stratio.provider.mongodb").options(options).load();
df.show();
}
}
Hi,
when I connect to mongodb from terminal I pass User, Password and AuthenticationDatabase
how can i pass these arguments through this connector?
thanks