Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.sql.SQLException: Numeric Overflow

541 views
Skip to first unread message

Dgenius

unread,
Dec 16, 2001, 1:17:07 AM12/16/01
to
Hi,

I was trying to select data from a Oracle db table. However after reading in
one row, i get this above error.I don't think there is anything wrong with
my table.
Does anyone know where the problem lies - is it Oracle, or the JDBC drivers.

Here is the stuff I'm using:
JBuilder 5 Entperise - Tomcat 3
win2k
Oracle 8.1.7
std jdbc drivers that come with oracle.


Here is the stack trace for the exception.
java.sql.SQLException: Numeric Overflow
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
at
oracle.jdbc.driver.OracleStatement.getIntValue(OracleStatement.java:3143)
at
oracle.jdbc.driver.OracleResultSetImpl.getInt(OracleResultSetImpl.java:329)
at pqparcels.CustomerManager.retrieveTableData(CustomerManager.java:43)
at pqparcels.TestDriver.main(TestDriver.java:17)

Here is the code:
public void retrieveTableData()
{
//obtain a connection to the database via jdbc.
conn = dbConn.establishConnection();

//formulating the query to execute against db
strQuery = "select * from customer";

try
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(strQuery);

while (rs.next())
{
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " +
rs.getString(3) +
" " + rs.getString(4) + " " + rs.getString(5) + "
" + rs.getString(6) +
" " + rs.getInt(7));
System.out.println("Crashed on first iteration");
}
//closing the db connection
conn.close();
}
catch(SQLException e)
{
e.printStackTrace();
}


Thanks in advance.


Lee Fesperman

unread,
Dec 16, 2001, 1:33:26 AM12/16/01
to
Dgenius wrote:
>
> Hi,
>
> I was trying to select data from a Oracle db table. However after reading in
> one row, i get this above error.I don't think there is anything wrong with
> my table.
> Does anyone know where the problem lies - is it Oracle, or the JDBC drivers.

It does depend on what your table definition is and what's in your table (at least the
first row). You didn't show that.

> java.sql.SQLException: Numeric Overflow
> ...


>
> System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " +
> rs.getString(3) +
> " " + rs.getString(4) + " " + rs.getString(5) + "
> " + rs.getString(6) +
> " " + rs.getInt(7));

The stacktrace showed it failed in getInt(), so I would say that column 1 or column 7
either has a number too big for Java int or doesn't contain a number at all. Do a
getObject() to get some idea what is in there.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
===================================================================
* Check out Database Debunkings (http://www.firstsql.com/dbdebunk/)
* "Where Persistent Prevailing Database Fallacies Are Dispelled"

Joseph Weinstein

unread,
Dec 17, 2001, 2:42:21 PM12/17/01
to Dgenius

Dgenius wrote:
>
> Hi,
>
> I was trying to select data from a Oracle db table. However after reading in
> one row, i get this above error.I don't think there is anything wrong with
> my table.
> Does anyone know where the problem lies - is it Oracle, or the JDBC drivers.
>
> Here is the stuff I'm using:
> JBuilder 5 Entperise - Tomcat 3
> win2k
> Oracle 8.1.7
> std jdbc drivers that come with oracle.
>
> Here is the stack trace for the exception.
> java.sql.SQLException: Numeric Overflow
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
> at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
> at
> oracle.jdbc.driver.OracleStatement.getIntValue(OracleStatement.java:3143)
> at
> oracle.jdbc.driver.OracleResultSetImpl.getInt(OracleResultSetImpl.java:329)
> at pqparcels.CustomerManager.retrieveTableData(CustomerManager.java:43)

It does matter what's in the table. Note that Oracle DDL allows you to define
a column to be integer or int, but the DBMS doesn't really have a normal
int column type. Instead you really get a DECIMAL(39), which is bigger
than a 64-bit long! You may simply have a bigger value that can be converted
to a Java int in your 'int' column.

Joe Weinstein at B.E.A.

--
B.E.A. is now hiring! (12/14/01) If interested send a resume to j...@bea.com

DIRECTOR OF PRODUCT PLANS AND STRATEGY San Francisco, CA
E-SALES BUSINESS DEVELOPMENT REPRESENTATIVE Dallas, TX
SOFTWARE ENGINEER (DBA) Liberty Corner, NJ
SENIOR WEB DEVELOPER San Jose, CA
SOFTWARE ENGINEER (ALL LEVELS), CARY, NORTH CAROLINA San Jose, CA
SR. PRODUCT MANAGER Bellevue, WA
SR. WEB DESIGNER San Jose, CA
Channel Marketing Manager - EMEA Region London, GBR
DIRECTOR OF MARKETING STRATEGY, APPLICATION SERVERS San Jose, CA
SENIOR SOFTWARE ENGINEER (PLATFORM) San Jose, CA
E-COMMERCE INTEGRATION ARCHITECT San Jose, CA
QUALITY ASSURANCE ENGINEER Redmond, WA
Services Development Manager (Business Development Manager - Services) Paris, FRA; Munich, DEU
SENIOR SOFTWARE ENGINEER (PLATFORM) Redmond, WA
E-Marketing Programs Specialist EMEA London, GBR
BUSINESS DEVELOPMENT DIRECTOR - E COMMERCE INTEGRATION San Jose, CA
MANAGER, E-SALES Plano, TX

Avi Abrami

unread,
Dec 30, 2001, 9:44:20 PM12/30/01
to
[Advertisement snipped.]

Hi D,
I always use java.math.BigDecimal class to map Oracle database table
columns of type NUMBER, no matter what the exact column definition is.
I have encountered no problems when using this approach.

HTH,
Avi.

Avi Abrami

unread,
Dec 30, 2001, 9:44:20 PM12/30/01
to
[Advertisement snipped.]

Hi D,
I always use java.math.BigDecimal class to map Oracle database table
columns of type NUMBER, no matter what the exact column definition is.
I have encountered no problems when using this approach.

HTH,
Avi.

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool0-nwblwi.newsops.execpc.com!newsfeeds.sol.net!priapus.visi.com!news-out.visi.com!hermes.visi.com!newsxfer.interpacket.net!news-xfer.nuri.net!news-hub.kaist.ac.kr!feeder.kornet.net!news1.kornet.net!u-n-c-a-n-c-e-l-l-e-r
From: Avi Abrami <abr...@yahoo.com>
Newsgroups: comp.lang.java.databases
Subject: cmsg cancel <3C2FD104...@yahoo.com>
Control: cancel <3C2FD104...@yahoo.com>
Date: Mon, 31 Dec 2001 05:20:20 GMT
Organization: Korea Telecom
Lines: 2
Message-ID: <cancel.3C2FD...@yahoo.com>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news1.kornet.net 1009787046 9658 211.57.49.2 (31 Dec 2001 08:24:06 GMT)
X-Complaints-To: use...@feeder.kornet.net
NNTP-Posting-Date: Mon, 31 Dec 2001 08:24:06 +0000 (UTC)
X-No-Archive: yes
Comment: Anarchy! Fuck You!
X-Commentary: I love NewsAgent 1.10, Sandblaster Build 74 (19 March 1999) and the Polaris Cancel Engine V. 6.1
X-Unacanc3l: yes

This message was cancelled from within Mozilla...not

AV

unread,
Jan 3, 2002, 8:24:46 AM1/3/02
to
"Avi Abrami" <abr...@yahoo.com> wrote in message
news:3C2FD104...@yahoo.com...

Yet another approach is to investigate DDL :
NUMBER(N,M) can be bind to Java type
-- integer with N <=9, M=0
-- long with N <=16, M=0
-- BigDecimal in any other cases.

AlexV

0 new messages