मेरे पास एक पाइपलाइन है जो डेटा MySQL लाती है और नीचे दिए गए कोड के साथ इस पाइपलाइन को चलाने के बाद डेटा को मोंगो डीबी में स्थानांतरित करने के लिए उपयोग की जाती है, डेटा MySQL से प्राप्त किया जाता है लेकिन मोंगोडब को लोड करने में असमर्थ होता है
noSqlresult.apply(MongoDbIO.write().withUri(mongoUri)
.withDatabase(mongoDatabase)
.withCollection(resultCollectionName));
मुझे निम्नलिखित अपवाद और कुछ लॉग मिले हैं जो लगातार मोंगो डीबी के साथ संवाद करने की कोशिश कर रहे हैं:
com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='mongoUser', source='db1', password=<hidden>, mechanismProperties={}}
at com.mongodb.connection.SaslAuthenticator.wrapException(SaslAuthenticator.java:162)
at com.mongodb.connection.SaslAuthenticator.access$200(SaslAuthenticator.java:39)
at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:68)
at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:46)
at com.mongodb.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:168)
at com.mongodb.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:46)
at com.mongodb.connection.DefaultAuthenticator.authenticate(DefaultAuthenticator.java:32)
at com.mongodb.connection.InternalStreamConnectionInitializer.authenticateAll(InternalStreamConnectionInitializer.java:122)
at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:52)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:127)
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server severip:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }
at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:164)
at com.mongodb.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:295)
at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255)
at com.mongodb.connection.CommandHelper.sendAndReceive(CommandHelper.java:84)
at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:34)
at com.mongodb.connection.SaslAuthenticator.sendSaslStart(SaslAuthenticator.java:119)
at com.mongodb.connection.SaslAuthenticator.access$000(SaslAuthenticator.java:39)
at com.mongodb.connection.SaslAuthenticator$1.run(SaslAuthenticator.java:52)
... 9 more
18/11/09 12:49:29 DEBUG org.mongodb.driver.cluster: Updating cluster description to {type=UNKNOWN, servers=[{address=severip:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='mongoUser', source='db1', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server severip:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}]
18/11/09 12:49:29 DEBUG org.mongodb.driver.connection: Closing connection connectionId{localValue:17}
18/11/09 12:49:29 DEBUG org.mongodb.driver.cluster: Updating cluster description to {type=UNKNOWN, servers=[{address=severip:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='mongoUser', source='db1', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server severip:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}]
18/11/09 12:49:29 DEBUG org.mongodb.driver.connection: Closing connection connectionId{localValue:18}
ऐसे मामलों को कैसे संभालना है यदि मौजूद नहीं है तो मोंगो में डीबी बनाने की क्षमता है लेकिन कनेक्ट करने के लिए मोंगो क्लाइंट का उपयोग करके आंतरिक रूप से मोंगोआईओ नहीं बना रहा है। क्या संभालने की कोई संभावना है
इसे दिखाने में त्रुटि ध्यान की समस्या के कारण है, लेकिन मौजूदा डेटाबेस के लिए अपवाद नहीं मिल रहा है केवल नए डेटाबेस प्राप्त करना सटीक कारण क्या है और उन त्रुटियों को कैसे संभालना है
1 उत्तर
Ptransform के परिणाम को संग्रहीत करने के लिए कोई वस्तु नहीं है, इसलिए कनेक्शन टाइम-आउट अपवाद की प्रतीक्षा करने की आवश्यकता है, उसके बाद आप उन कार्यों को कर सकते हैं जिन्हें आप कैच ब्लॉक में घोषित करते हैं यदि अन्य कनेक्शन स्वचालित रूप से बंद हो जाते हैं।
यदि आप अपवाद को संभालने के लिए नए हैं, तो मुझे लगता है कि आपको निम्न लिंक से उत्तर मिलेगा
java_exception_handler_StackOverFlow
संबंधित सवाल
जुड़े हुए प्रश्न
नए सवाल
java
जावा एक उच्च स्तरीय प्रोग्रामिंग भाषा है। इस टैग का उपयोग तब करें जब आपको भाषा का उपयोग करने या समझने में समस्या हो। इस टैग का उपयोग शायद ही कभी किया जाता है और इसका उपयोग अक्सर [वसंत], [वसंत-बूट], [जकार्ता-ई], [Android], [javafx], [हडूप], [श्रेणी] और [मावेन] के साथ किया जाता है।