question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResultSet getObject with class return null values filled as it was not null

See original GitHub issue

When selecting values from table with getObject(index, Class) simple types (like float/int/boolean) return 0/false as result (when null is expected).

CREATE TABLE db.tbl
   (
   id int not null,
   double_col double,
   float_col float,
   varchar_col varchar(36),
   boolean_col boolean,
   int_col int,
   bigint_col bigint,
   char_col char(10),
   int32_col int32
   primary key (id)
   )
   distributed by (id)

Expected: [1, null, null, null, null, null, null, null, null] Actual: [1, 0.0, 0.0, null, false, 0, 0, null, 0]

getObject(int columnIndex) returns null as expected.

Is that expected behaivor? (it breaks Vertx jdbc client as it always uses getObject with expected class)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
FDoKEcommented, Jul 4, 2022

@zhicwu dbeaver probably using getObject(index) to retrieve column values simple reproducer:

Connection connection = DriverManager.getConnection("jdbc:clickhouse://clickhouse:8123/default");
Statement statement = connection.createStatement();
statement.execute("select double_col from db.table");
ResultSet resultSet = statement.getResultSet();
resultSet.next();
Object object1 = resultSet.getObject(1); // returns null
Double object2 = resultSet.getObject(1, Double.class); // returns 0.0
0reactions
FDoKEcommented, Jul 4, 2022

Yeah, that seems strange to me too, why would they do that if it perfectly worked with getObject(int), I made an issue for them too to get their idea behind this change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checking for a null int value from a Java ResultSet
Unfortunately, getObject(columnName, Class) does not return null, but the default value for given Java type, so 2 calls are required
Read more >
ResultSet.getObject() Returns Null Wrongly If Using JDBC OCI
ResultSet.getObject() or ResultSet.getString() return null or empty although a valid value is stored in a table. This issue is reproduced ...
Read more >
java.sql.ResultSet.wasNull java code examples - Tabnine
Gets the value of a column specified by column name, as an intvalue. close. Releases this ResultSet's database and JDBC resources. You are...
Read more >
JDK-4029237 JDBC Problems with NULL Data ... - Bug ID
When I get a ResultSet back from a query, problems occur if a column contains null and the columns are not access in...
Read more >
ResultSet - Android Developers
A table of data representing a database result set, which is usually generated by executing a ... If the value is SQL NULL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found