You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexander Belyak (Jira)" <ji...@apache.org> on 2022/04/09 08:22:00 UTC
[jira] [Created] (IGNITE-16830) Wrong prepared statement type casting
Alexander Belyak created IGNITE-16830:
-----------------------------------------
Summary: Wrong prepared statement type casting
Key: IGNITE-16830
URL: https://issues.apache.org/jira/browse/IGNITE-16830
Project: Ignite
Issue Type: Bug
Components: jdbc
Affects Versions: 2.11.1
Reporter: Alexander Belyak
Apache Ignite ignores numeric parameter types in PreparedStatement. I mean it ignores "long" type of parameter and uses it as an integer, so
{noformat}
select 912456000000 - ? * 86400000{noformat}
{color:#172b4d}with parameter value (long)220
{color}
{noformat}
try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
//try(Connection conn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","postgres", "postgres")) {
try (PreparedStatement select = conn.prepareStatement("select 912456000000 - ? * 86400000")) {
select.setLong(1, 220);
ResultSet rs = select.executeQuery();
rs.next();
System.out.println("======== " + rs.getLong(1));
}
}
{noformat}
{color:#172b4d}leads to
{color}
{noformat}
Numeric value out of range: "19008000000"{noformat}
on Ignite, but work great on PGSQL (for example).
And it works if we convert the parameter explicitly:
{noformat}
select 912456000000 - cast(? as bigint) * 86400000{noformat}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)