java - Issue with UNSIGNED BIGINT of MySQL while fetching using JDBC client -


as per mysql docs, maximum value unsinged bigint = 18446744073709551615

i inserted value 9223372036854776900 (far lower max limit) in unsinged bigint column.

no error shown.

when tried access programmatically via jdbc client, got exception:

com.mysql.jdbc.exceptions.jdbc4.mysqldataexception: '9223372036854776900' in column '10' outside valid range datatype bigint. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:422) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.util.getinstance(util.java:386) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1026) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:987) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:982) @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:927) @ com.mysql.jdbc.resultsetimpl.throwrangeexception(resultsetimpl.java:7964) @ com.mysql.jdbc.resultsetimpl.parselongasdouble(resultsetimpl.java:7248) @ com.mysql.jdbc.resultsetimpl.getlong(resultsetimpl.java:2946) @ com.mysql.jdbc.resultsetimpl.getlong(resultsetimpl.java:2911)


mysql version : 5.5.41-0ubuntu0.14.04.1

as suggested stack trace, able recreate issue when tried use resultset#getlong

long l = rs.getlong(1); 

because stored value, 9223372036854776900, larger maximum value (signed) long in java: 9223372036854775807.

however, able retrieve value bigdecimal using

java.math.bigdecimal bd = rs.getbigdecimal(1); 

or biginteger using

java.math.biginteger bi = (java.math.biginteger) rs.getobject(1); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -