元Sabry:
私はMongoDBのにかなり新しいと私はMongoDBのデータベースにアレイからのデータを保存する方法についての問題を持っていますか?私は以下のコードを実装し、いくつかの理由で、私は、エラーの多くを得ます。
private void storeData(String[] trainSeats, String[] customerName, String[] traincustomerSeats){
MongoClient dbb = new MongoClient("localhost", 27017);
DB dbs = dbb.getDB("Train Customers and Seats");
DBCollection coll1 = dbs.getCollection("CW1");
DBCollection coll2 = dbs.getCollection("CW2");
DBCollection coll3 = dbs.getCollection("CW3");
BasicDBObject oneDoc = new BasicDBObject();
for (int k = 1; k < trainSeats.length; k++){
oneDoc.append(String.valueOf(k), trainSeats[k]);
}
coll1.insert(oneDoc);
BasicDBObject twoDoc = new BasicDBObject();
for(int k = 1; k < customerName.length; k++){
twoDoc.append(String.valueOf(k), customerName[k]);
}
coll2.insert(twoDoc);
BasicDBObject threeDoc = new BasicDBObject();
for(int k = 1; k < traincustomerSeats.length; k++){
threeDoc.append(String.valueOf(k), traincustomerSeats[k]);
}
coll3.insert(threeDoc);
optionEnter(trainSeats,customerName,traincustomerSeats);
}
ここで私は上記のコードを実行したときに私が得るエラーは以下のとおりです。
umair:
私はあなたのエラーログを見ました。データベース名ため、このエラーを得ている「電車のお客様と席は」たくさんの持っているスペース 「」データベース名に許可されていません。
「Train_Customers_and_Seats」または「TrainCustomersAndSeats」にデータベースの名前を変更します