• Type: Icon: Task Task
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      I trying to connect server but I am getting this error

      Error
      _com.mongodb.MongoTimeoutException:
      Timed out after 3000 ms while waiting to connect. Client view of cluster state is
      {type=UNKNOWN,
      servers=[{
      address=<server_address>:27017,
      type=UNKNOWN,
      state=CONNECTING,
      exception=

      { com.mongodb.MongoException: java.lang.NoClassDefFoundError: com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient }

      ,
      caused by

      {java.lang.NoClassDefFoundError: com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient}

      }]_

      This is my Code:
      _MongoClientOptions.Builder o = MongoClientOptions.builder().serverSelectionTimeout(3000);
      MongoCredential credential = MongoCredential.createCredential("admin", "<database_name>","admin".toCharArray());

      // Creating a Mongo client
      MongoClient mongo = new MongoClient( new ServerAddress("<server_address>" , 27017),credential,o.build());

      System.out.println("Connected to the database successfully ");

      // Accessing the database
      MongoDatabase database = mongo.getDatabase("<database_name>");
      System.out.println("Collection created successfully");
      // Retrieving a collection
      MongoCollection<Document> collection = database.getCollection("<collection_name>");
      System.out.println("Collection sampleCollection selected successfully ");

      //Getting the iterable object
      FindIterable<Document> iterDoc = collection.find();
      int i = 1;

      String s = null;
      // Getting the iterator
      Iterator it = null;
      try {
      it = iterDoc.iterator();
      while (it.hasNext())

      { System.out.println(it.next()); s+=it.next().toString(); i++; }

      } catch (Exception e)

      { e.printStackTrace(); Log.i("TAG",""+e); }

      return s;_

            Assignee:
            Unassigned Unassigned
            Reporter:
            pritam@affwl.com pritam dhuri
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: