4

Not able to save java.sql.Date field using DBCollection.save()

Error : CodecConfigurationException: Can't find a codec for class java.sql.Date.

while insert() method has constructor having DBEncoder field.

DBCollection.insert(List<? extends DBObject> documents, WriteConcern aWriteConcern, DBEncoder dbEncoder)

But any kind of constructor for save() method.

1 Answer 1

3

You need to change your Date object from java.sql.Date to java.util.Date

java.util.Date newDate = new Date(yourSqlDate.getTime());

if you don't know when did you use java.sql.Date in your code, I suggest you should try to check if there are any Date variable that is update from SQL statement.

You should not have any problem if you use Mongo 2.x library, but since Mongo 3.x library, seems they removed the java.sql.Date support.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.