Closed juvation closed 6 years ago
My hunch is the node-java uses java.lang.Double
as the default representation of javascript numeric types (which your call to getTime()
returns).
You should be able to manually create a java.lang.Long
value with something along the lines of the following:
var javaLong = java.newInstanceSync("java.lang.Long", new Date().getTime().toString());
The numeric has to be converted to a String so the proper long constructor is used. The javaLong
value can then be fed into setLongSync
on your prepared statement.
Closing. Feel free to re-open if this solution doesn't work for you.
The database I'm attempting to talk to with Node JDBC maps dates as big integers, so I duly passed along new Date().getTime() to PreparedStatement.setInt() or setLong(). This results in the error message --
could not prepare statement: Could not find method "setLong(java.lang.Integer, java.lang.Double)
I tried a workaround which calls setDouble() if the integer going in is bigger than Math.pow(2,31), which works. (I don't know what the actual limit is.)
It's unclear what the interface should do if the number is bigger than a Java long can deal with -- convert to BigDecimal, perchance.