Numeric overflow exception in java jdbc

This query returns a numerical overflow exception. Values ​​from 1 to 14 are easy to extract, but large values ​​(from 15 to) cannot be.

I am using ORACLE XE. How to fix it?

Here is 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 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) )
+4
source share
2 answers

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

Try using Long and rs.getLong(15);

+8
source

, "". , , Java BigDecimal. , Oracle NUMBER. , jdbc oracle.sql.NUMBER.

0

Source: https://habr.com/ru/post/1538829/


All Articles