Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC driver incorrectly converts TINYINT fields to String instead of an integer type. #4026

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working Client interfaces normal

Comments

@monetdb-team
Copy link

Date: 2016-06-27 11:24:33 +0200
From: Erik Berglund <<erik.berglund>>
To: clients devs <>
Version: 11.23.3 (Jun2016)

Last updated: 2016-07-22 09:56:10 +0200

Comment 22211

Date: 2016-06-27 11:24:33 +0200
From: Erik Berglund <<erik.berglund>>

User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
Build Identifier:

When requesting the result of a query as an object, the JDBC driver returns TINYINT fields as String objects instead of, for example Short or Integer objects.

Reproducible: Always

Steps to Reproduce:

Java code to replicate:
Connection c = ...
PreparedStatement ps = c.prepareStatement("create table foo (bar tinyint)");
ps.execute();
ps.close();
ps = c.prepareStatement("insert into foo (bar) values(99)");
ps.execute();
ps.close();
ps = c.prepareStatement("select bar from foo");
ResultSet rs = ps.executeQuery();
if(rs.next())
{
//causes exception:
Short value = (Short) rs.getObject(1);
}
ps.close();
ps = c.prepareStatement("drop table foo ");
ps.execute();
ps.close();

Actual Results:

Instead of returning an object of an integer class (Integer, Short, or Long) the driver returns a String object with the result encoded as text.

Expected Results:

The driver should return a type that as closely matches the type of the database column as possible.

This happens every time on 32 bit windows 7, but only intermittently on 64-bit Ubuntu 16.04 with the MonetDB version included in that distribution's repository (Jun2016).

Comment 22219

Date: 2016-06-30 16:03:33 +0200
From: MonetDB Mercurial Repository <>

Changeset ac8dddcdeaf5 made by Martin van Dinther martin.van.dinther@monetdbsolutions.com in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=ac8dddcdeaf5

Changeset description:

Added missing case for type == Short.class which is needed for SQL smallint and tinyint columns.
Added Java test program Test_PSgetObject.
This fixes bug #4026.
Also improved handling of getObject(int colnr, Map<String,Class<?>> map) input arguments.
When colnr is invalid it now throws a proper SQLException.
When map is null it falls back to internal default mapping as defined in getClassForType().

Comment 22233

Date: 2016-07-05 16:38:06 +0200
From: @sjoerdmullender

I understand the commit fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client interfaces normal
Projects
None yet
Development

No branches or pull requests

2 participants