EDIT: Please point out if others are not seeing this issue, and I am doing something wrong.
I am trying to add rows to a table containing single VerticaDayTimeInterval column through the VerticaDayTimeInterval constructor. The precision and fractional values are being wrongly printed and on retrieving precision for all 6 irrespective of what I gave earlier.
dayInt = new VerticaDayTimeInterval(10, 10, 01, 8, 2, 1, false) ; ((VerticaPreparedStatement) pstmt).setObject(1, dayInt) ; pstmt.addBatch() ; System.out.println(dayInt.toString());
dayInt = new VerticaDayTimeInterval(10, 10, 02, 7, 3, 2, false) ; ((VerticaPreparedStatement) pstmt).setObject(1, dayInt) ; pstmt.addBatch() ; System.out.println(dayInt.toString());
dayInt = new VerticaDayTimeInterval(10, 10, 03, 6, 43, 3, false) ; ((VerticaPreparedStatement) pstmt).setObject(1, dayInt) ; pstmt.addBatch() ; System.out.println(dayInt.toString());
table output
DayInt
-------------------
10 10:03:49.000211
11 07:00:00.0002
9 09:09:05.000005
(3 rows)
retriving and printing rows with resultset.
for (int x=1 ; rs.next() ; ++x) {
VerticaDayTimeInterval dti = (VerticaDayTimeInterval)(rs.getObject(1));
System.out.println("vertica object tostring "+dti.toString()+" frac "+dti.getFraction()+" precision "+dti.getPrecision());
}
Output
vertica object tostring 10 10:03:49.211000 frac 211000 precision 6
vertica object tostring 11 07:00:00.200000 frac 200000 precision 6
vertica object tostring 9 09:09:05.500000 frac 500000 precision 6
My code is similar to https://my.vertica.com/docs/7.1.x/HTML/Content/Authoring/ConnectingToHPVertica/ClientJDBC/UsingIntervalsWithJDBC.htm
rs.next
doing, how are you getting this data from the table? it is possible that the method may be the cause of your problems. Edit: Your code looks correct, I think the issue is caused in how you are retrieving the data from the table. – Dairy(VerticaDayTimeInterval)(rs.getObject(1));
have you triedrs.getObject(1, VerticaDayTimeInterval)
? – Dairy