Sybase ASE Unsigned Integer returns values of Integer :
create table #x
(i unsigned int null)
insert into #x
select 2000000000
union
select 4294967039
union
select 4294967040
union
select 4294967295
union
select 4294967294
union
select 4294967293
union
select 4294967292
union
select 4294967291
union
select 4294967290
union
select 4294967289
union
select 4294967288
select * from #x
drop table #x
![]() |
4 KB
|
99 KB
I was able to reproduce this problem with ADS 10.0 and above. I was also able to reproduce the problem with jConnect6 and the latest jConnect7. The problem seems to be the jConnect JDBC drivers. When returning the resultset, the JDBC driver will report the column type as an "int" (ResultSetMetaData.
getColumnType()) and returns a Java "Integer" object (ResultSet.getObject()).
Sybase 15 introduced the "unsigned int" datatype which stores values : " Whole numbers between 0 and 4,294,967,295"
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1550/html/blocks/blocks20.htm
Java Integer objects stores values : " It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)"
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
The jConnect JDBC driver seems to receive the value from the network, but then identifies and converts it to an Integer object. If the value is greater then 2,147,483,647 then it will circle around to the negative representation. I quickly tried the ResultSet.getLong() method and that seems to return the correct value representation.
I will create a simple Java application that will test all new UNSIGNED datatypes and log an issue with Sybase. I don't know what the turn around will be from Sybase, so we will also try to implement a workaround in ADS 10.0.x. We should be able to implement a workaround if the jConnect JDBC driver can correctly identify the column as an UNSIGNED int.
I logged this with Sybase as Case #11755481. Sybase indicated that the current behavior is as designed according to docs :
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc31652.1570/html/java/CHDHGHGI.htm
I indicated that the design is incorrect since :
Sybase 15 introduced the "unsigned int" datatype which stores values : " Whole numbers between 0 and 4,294,967,295"
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1550/html/blocks/blocks20.htm
Java Integer objects stores values : " It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)"
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
So they have opened CR720067 for the Engineering to look into this.
I logged this with Sybase as Case #11755481. Sybase indicated that the current behavior is as designed according to docs :
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc31652.1570/html/java/CHDHGHGI.htm
I indicated that the design is incorrect since :
Sybase 15 introduced the "unsigned int" datatype which stores values : " Whole numbers between 0 and 4,294,967,295"
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1550/html/blocks/blocks20.htm
Java Integer objects stores values : " It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)"
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
So they have opened CR720067 for the Engineering to look into this.
Database: Sybase ASE 16
Verified in ADS17.0.0-beta-20
Please refer screenshot: Fixed-ADS17-beta-20.png
Database: Sybase ASE 16
Verified in ADS17.0.0-beta-20
Please refer screenshot: Fixed-ADS17-beta-20.png
Issue #7623 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
No fixed build |
No time estimate |
I was able to reproduce this problem with ADS 10.0 and above. I was also able to reproduce the problem with jConnect6 and the latest jConnect7. The problem seems to be the jConnect JDBC drivers. When returning the resultset, the JDBC driver will report the column type as an "int" (ResultSetMetaData.
getColumnType()) and returns a Java "Integer" object (ResultSet.getObject()).
Sybase 15 introduced the "unsigned int" datatype which stores values : " Whole numbers between 0 and 4,294,967,295"
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1550/html/blocks/blocks20.htm
Java Integer objects stores values : " It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive)"
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
The jConnect JDBC driver seems to receive the value from the network, but then identifies and converts it to an Integer object. If the value is greater then 2,147,483,647 then it will circle around to the negative representation. I quickly tried the ResultSet.getLong() method and that seems to return the correct value representation.
I will create a simple Java application that will test all new UNSIGNED datatypes and log an issue with Sybase. I don't know what the turn around will be from Sybase, so we will also try to implement a workaround in ADS 10.0.x. We should be able to implement a workaround if the jConnect JDBC driver can correctly identify the column as an UNSIGNED int.