List of usage examples for com.mongodb ServerAddress ServerAddress
public ServerAddress(final InetSocketAddress inetSocketAddress)
From source file:testt.mongoConnector.java
public mongoConnector() throws UnknownHostException { /*// ww w . j a va 2s . c o m * this section won't cause any exception yet, exception will be thrown * when committing update to the database */ Scanner sc = new Scanner(System.in); String pwd; System.out.print("password:"); pwd = sc.next(); /*char [] pwd; pwd = System.console().readPassword();*/ MongoCredential mc = MongoCredential.createCredential("rwmy", "myDB", pwd.toCharArray()); ServerAddress sa = new ServerAddress("localhost"); client = new MongoClient(sa, Arrays.asList(mc)); db = client.getDB("myDB"); coll = db.getCollection("websites"); client.setWriteConcern(WriteConcern.ACKNOWLEDGED); }