- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的代码:
DateTime dateTime = new DateTime();
BasicDBObject oldDoc = new BasicDBObject("email",email);
BasicDBObject newDoc = new BasicDBObject("$set",new BasicDBObject("office_move_date",dateTime.toDateTime()));
collection.update(oldDoc,newDoc);
错误消息:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8413)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
... 48 more Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.joda.time.DateTime.
at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:212)
at com.mongodb.DBObjectCodec.encodeMap(DBObjectCodec.java:222)
at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:198)
at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:130)
at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61)
at org.bson.BsonDocumentWrapper.getUnwrapped(BsonDocumentWrapper.java:195)
at org.bson.BsonDocumentWrapper.isEmpty(BsonDocumentWrapper.java:115)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:389)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:371)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
at com.mongodb.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:74)
at com.mongodb.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:58)
at com.mongodb.connection.BsonWriterHelper.writePayloadArray(BsonWriterHelper.java:50)
at com.mongodb.connection.SplittablePayloadBsonWriter.writeEndDocument(SplittablePayloadBsonWriter.java:53)
at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:118)
at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:41)
at com.mongodb.connection.CommandMessage.addDocumentWithPayload(CommandMessage.java:166)
at com.mongodb.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:148)
at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:145)
at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:245)
at com.mongodb.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:98)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:441)
at com.mongodb.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:76)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:189)
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:263)
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:126)
at com.mongodb.operation.MixedBulkWriteOperation.executeCommand(MixedBulkWriteOperation.java:373)
at com.mongodb.operation.MixedBulkWriteOperation.executeBulkWriteBatch(MixedBulkWriteOperation.java:255)
at com.mongodb.operation.MixedBulkWriteOperation.access$700(MixedBulkWriteOperation.java:66)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:199)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:190)
at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:432)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:190)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:147)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:52)
at com.mongodb.Mongo$3.execute(Mongo.java:833)
at com.mongodb.Mongo$3.execute(Mongo.java:814)
at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:341)
at com.mongodb.DBCollection.update(DBCollection.java:563)
at com.mongodb.DBCollection.update(DBCollection.java:486)
at com.mongodb.DBCollection.update(DBCollection.java:463)
at com.mongodb.DBCollection.update(DBCollection.java:441)
at com.mongodb.DBCollection.update(DBCollection.java:505)
at com.mongodb.DBCollection.update(DBCollection.java:520)
at com.application.Menu.officeMove.ControllerOfficeMove.confirmBtnClicked(ControllerOfficeMove.java:76)
... 58 more
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
... 48 more Caused by: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.joda.time.DateTime.
at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:212)
at com.mongodb.DBObjectCodec.encodeMap(DBObjectCodec.java:222)
at com.mongodb.DBObjectCodec.writeValue(DBObjectCodec.java:198)
at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:130)
at com.mongodb.DBObjectCodec.encode(DBObjectCodec.java:61)
at org.bson.BsonDocumentWrapper.getUnwrapped(BsonDocumentWrapper.java:195)
at org.bson.BsonDocumentWrapper.isEmpty(BsonDocumentWrapper.java:115)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:389)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:371)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
at com.mongodb.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:74)
at com.mongodb.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:58)
at com.mongodb.connection.BsonWriterHelper.writePayloadArray(BsonWriterHelper.java:50)
at com.mongodb.connection.SplittablePayloadBsonWriter.writeEndDocument(SplittablePayloadBsonWriter.java:53)
at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:118)
at org.bson.codecs.BsonDocumentCodec.encode(BsonDocumentCodec.java:41)
at com.mongodb.connection.CommandMessage.addDocumentWithPayload(CommandMessage.java:166)
at com.mongodb.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:148)
at com.mongodb.connection.RequestMessage.encode(RequestMessage.java:145)
at com.mongodb.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:245)
at com.mongodb.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:98)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:441)
at com.mongodb.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:76)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:189)
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:263)
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:126)
at com.mongodb.operation.MixedBulkWriteOperation.executeCommand(MixedBulkWriteOperation.java:373)
at com.mongodb.operation.MixedBulkWriteOperation.executeBulkWriteBatch(MixedBulkWriteOperation.java:255)
at com.mongodb.operation.MixedBulkWriteOperation.access$700(MixedBulkWriteOperation.java:66)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:199)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:190)
at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:432)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:190)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:147)
at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:52)
at com.mongodb.Mongo$3.execute(Mongo.java:833)
at com.mongodb.Mongo$3.execute(Mongo.java:814)
at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:341)
at com.mongodb.DBCollection.update(DBCollection.java:563)
at com.mongodb.DBCollection.update(DBCollection.java:486)
at com.mongodb.DBCollection.update(DBCollection.java:463)
at com.mongodb.DBCollection.update(DBCollection.java:441)
at com.mongodb.DBCollection.update(DBCollection.java:505)
at com.mongodb.DBCollection.update(DBCollection.java:520)
at com.application.Menu.officeMove.ControllerOfficeMove.confirmBtnClicked(ControllerOfficeMove.java:76)
... 58 more
如何将 dateTime.toDateTime() 变量中的日期添加到 mongodb?
最佳答案
不支持 Joda,您必须使用 java.util.Date
相反,如果您已经使用 Joda 或 java.time
Java 8 库,您必须将其转换为 java.util.Date
根据您的情况,您可以使用:
getJodaDateTime();//Your dateTime
java.util.Date utilDate = getJodaDateTime().toDate();//Convert it to java.util.Date
BasicDBObject newDoc = new BasicDBObject("$set",
new BasicDBObject("office_move_date", utilDate)
);
<小时/>
但是在您的情况下,将 org.joda.time.DateTime
转换为 java.util.Date
没有任何意义,您可以直接使用 java.util。日期
:
BasicDBObject newDoc = new BasicDBObject("$set",
new BasicDBObject("office_move_date", new java.util.Date())//<--- Use just this
);
关于java - MongoDB jodatime : org. bson.codecs.configuration.CodecConfigurationException : Can't find a codec for class org. joda.time.DateTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48135586/
我试图理解 BSON 符号 来自网站 BSON Site .但是,我无法理解相关性背后的原因。 我也提到了以下问题,但由于以下原因,我不相信。 Question 1 : 不熟悉 ruby 实现 Que
我收到以下错误: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson:
假设我们有一个字符串,里面有二进制 bson 数据。如何加载到 bson object ? 最佳答案 我想在同一个页面上有一个例子可以做到这一点: BSONObjBuilder b; b << "na
我正在寻找如下所示的 type_of 方法: import bson bson.type_of(42) # it should return "int". bson.type_of("hello")
Base64 编码的 BSON 比 BSON 小吗? 最佳答案 Piskvor 的权利,base64 编码的任何东西都比原始长。您对某些内容进行 base64 编码以使其进入具有有限字符轨道的 cha
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
这个特定的问题与使用 mongodb 和 golang 包 mongo-driver 相关。 ,但我认为这适用于与 mongodb 的大多数接口(interface)。 使用 Find 时要从集合中查
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
可能相关:How to use interface type as a model in mgo (Go)? 我有一个像这样的结构: type Game struct { ID b
有没有一种方法可以使用 MongoDB C++ 驱动程序中的 BSON() 宏来生成 BSON 将空值。例如,为了生成一个 BSON 来表示这个文档:{"a": "foo", "b": null}:
我通过以下两种不同的方法生成了一个 ObjectId: user@ubuntu:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
我如何转换 BsonDocument到 FilterDefinition实例? 它是新的 MongoDb C# 驱动程序提供的类。 最佳答案 BsonDocument 和 FilterDefiniti
我正在尝试从 Json 生成 Bson。我尝试使用 Json.Net,但似乎有记录的行为,其中库为整数字段生成 uint64。不幸的是,我们必须使用 uint32。 因此我正在尝试使用 mongodb
我正在使用 https://github.com/mongodb/mongo-go-driver和目前正在尝试实现此类结构的部分更新 type NoteUpdate struct { ID
我目前正在尝试读取 bson 文件以将其导入数据库。我已经可以读取该文件并将其作为字节打印,但最终只收到 bson.errors.InvalidBSON: objsize Too Large 错误。
我尝试在 arch linux 迷你计算机(cubox)上安装 mean.io 堆栈。所以我安装了 nodejs 和 mongodb 包。 我用 Git 检索了堆栈,进行了 npm 安装(没问题)但是
为什么会输出false?我期待 true... package main import ( "fmt" "time" "gopkg.in/mgo.v2/bson" )
这是一种愚蠢的语法错误,尝试了很多方法,但都无法正常工作,请大家帮忙。 使用 mgo 在 Go 中使用 MongoDB,我只是尝试简化 $ne 运算符的使用,代码如下所示,但不断出现编译语法错误: l
我设置了新的 Typescript/React 项目,在 tsconfig.json 文件中收到此错误消息 "找不到 'bson' 的类型定义文件。该文件在程序中,因为:隐式类型库 'bson' 的入
我尝试将数据从 SQL Server 迁移到 MongoDB,但在将数据导入到 MongoDB 的最后阶段遇到了以下类型错误。 mongoImp = dbo.insert_many(jArray)
我是一名优秀的程序员,十分优秀!