Question

This query returns a numeric overflow exception. Values from 1 to 14 are retrieved easily but bigger values (from 15 on) cannot be.

I am using ORACLE XE. How do I fix this?

Here's my code:

pst=con.prepareStatement("Select * from student where sut_id like 'Kul7Dub514'");
rs=pst.executeQuery();
while(rs.next)
{
    smob.setText(Integer.toString(rs.getInt(15)));
    fmob.setText(Integer.toString(rs.getInt(16)));
    mmob.setText(Integer.toString(rs.getInt(17)));
    col.setText(rs.getString(18));
    address.setText(rs.getString(19));
}

Student's table:

create table student ( stu_id varchar(10) primary key, stu_image Blob,
 stu_first_name varchar(20) not null,
 stu_middle_name varchar(20) not null,
 stu_last_name varchar(20) not null,
 fat_first_name varchar(20) not null,
 fat_middle_name varchar(20),
 fat_last_name varchar(20) not null,
 mot_first_name varchar(20),
 mot_middle_name varchar(20),
 mot_last_name varchar(20),
 dob Date,
 gender varchar(6),
 ac_yr varchar(10),
 mobno number(11),
 fatmob number(11),
 motmob number(11),
 edu_center varchar(50),
 address varchar(150) )
Was it helpful?

Solution

As the data in your DB is Number(11), this will not fit into an Integer.

Try a Long and rs.getLong(15);

OTHER TIPS

Most likely you do not perform any mathematical operations with that "numbers". Since you do not treat them as numbers, but as identifiers. You should use Java type BigDecimal. This is a type which is most similar to Oracle datatype NUMBER. Or you can also use datatype provided by jdbc drivers oracle.sql.NUMBER.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top