0

I have a query which fetches data and time from db, I am using addtime method of mysql to concat the two columns and return a single column.

IN mysql 5.5 the same query gave the result with return type as timestamp in java. I upgraded the db to 5.6 and now the result is in string and so the code gives exception that "String cannot be cast to Timestamp". My Query is

SELECT offerId , 
       status,  
       ADDTIME(effective_date_end, effective_time_end) asn endDateTime from offer

Data type of effective_date_end is date and that of effective_time_end is time.

After getting the result i am doing this in my java code.

java.sql.Timestamp)offerDetailMap.get("endDateTime")

This line now gives error.

Is there any way to get the two fields merged and return a time stamp in mysql 5.6?

2
  • 1
    Could you post the Java code which getting this error? Commented Feb 21, 2014 at 13:44
  • Timestamp offerEndDate = (java.sql.Timestamp)offerDetailMap.get("endDateTime") Commented Feb 21, 2014 at 13:45

1 Answer 1

1

As much as I would love to claim credit for an answer, I believe you might be looking for the answer given here: Convert Java String to sql.Timestamp

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

1 Comment

Thats working. But i want to retive the column with data type as Timestamp instead of string. This was working in 5.5.

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.