Select bigint data type value by using jdbc interface



I created a table STUDENT in which one ID column of data type bigint is present and inserted 2503188345 in table STUDENT.

If I am executing select query like
Select id from student;

Then I am getting 2503188345.

But If I am executing the above same select query by using jdbc interface to get the id of student, then I am getting value in negative.



Hi @Ishika -

Can you provide more context around how you are using jdbc? Either what tool/environment you are in or the code you wrote? That will help us debug what the issue might be rather than guess.



Hi @randyzwitch,

Thanks for the reply.
By using JDBC interface, like this I am doing

String sql = “SELECT ID from STUDENT”;
ResultSet rs = stmt.executeQuery(sql);

    while ( {
      String id = rs.getString(1);
      System.out.println(" id is "+id);



hi @Ishika
it’s a bug on jdbc driver that uses the getInt method when you ask a text representation of a BigInt field.

Could you try to change your code to String.valueOf(rs.getLong(1)) ?