Why am I unable to get millisecond data of a timestamp in my database using Database Toolbox 3.11 (R2012a)?

2 views (last 30 days)
I am trying to extract the timestamp from a given database using JDBC driver. The time data is captured as a cell array in the format HH:MM:SS. However, the time data contained milliseconds in the format HH:MM:SS.xxxxxx. I know this is not a limitation of cell array.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Jun 2012
For troubleshooting, try the following:
Curs = exec(conn, 'select <timestamp_col_name> from <timestamp_table_name> ')
Curs = fetch(curs);
A = attr(curs);
The JDBC driver should return A(1).typeValue as 93 for database toolbox to process it correctly and convert it to a string.
If it returns the value 92, it is a known limitation of java.sql.Time class which is what the code '92' stands for. The driver converts Database 'Time' object to a 'java.sql.Time' object which does not handle milli and micro seconds.
One way to work around this is to write custom Java code to use the 'getTimestamp' method and then convert it into a time string as attached. Note that this is just an example and you will have to review the code and make necessary changes to fit his requirements.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!