12

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) )
1
  • what is the meta-data for the student table. Commented May 1, 2014 at 8:23

2 Answers 2

21

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

Try a Long and rs.getLong(15);

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.