Hi all,
In JDBC using paramters in PreparedStatement, the result is different from using normal SQL.
For these two cases:
@Test public void test1() throws Exception { PreparedStatement ps = connection.prepareStatement( "select timeeq('FKB12_State', '2014-08-12 06:00:00.0', '2014-08-12 20:00:00.0', 1000)"); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { System.out.println(rs.getString(1)); } } } @Test public void test2() throws Exception { PreparedStatement ps = connection.prepareStatement( "select timeeq('FKB12_State', ?, ?, ?)"); ps.setTimestamp(1, Timestamp.valueOf("2014-08-12 06:00:00.0")); ps.setTimestamp(2, Timestamp.valueOf("2014-08-12 20:00:00.0")); ps.setFloat(3, 1000F); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { System.out.println(rs.getString(1)); } } }
The results are '00:00:01' and 'null' (a string of 'null' with 4 characters length).
I tried putting the parameters as ps.setString(), removing the trailing ".0" of the time stamps, even the timezone timing doesn't affect the result.
As you know, using native SQL could be dangerous and is not recommended.
Appreciate your help.
Ahmed
JDBC driver Manifest:
Implementation-Version: 0251
Specification-Vendor: OSIsoft, LLC.
Name: PIJDBC
Specification-Title: JDBC Driver via PI SQL Data Access Server
Specification-Version: 1.3.0