title: Simple program throws ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
body: <p>I am doing a simple program to connect MySQL database with Java, but the program throws the ClassCastException error.</p>
  
  <p><a href="https://stackoverflow.com/questions/3781218/java-long-to-mysql">Java long to MySql</a></p>
  
  <p>This question says that Unsigned Bigint in MySQL is equivalent to long in Java.</p>
  
  <p>Given below is the java part:</p>
  
  <pre><code>public static void main(String[] args) throws ClassNotFoundException, SQLException {
      // TODO code application logic here
  
      Class.forName("com.mysql.jdbc.Driver");
      Connection con = DriverManager.getConnection("jdbc:mysql:///check1","uname","pwd");
      Statement st = con.createStatement();
      ResultSet rs = st.executeQuery("select * from t1");
      while(rs.next()){
          System.out.println(rs.getObject(1)+ " "+ rs.getObject(2));
      }
      rs.close();
      st.close();
      con.close();
  }
  </code></pre>
  
  <p>I am also including the schema for the table I created</p>
  
  <pre><code>mysql&gt; desc t1;                                                                                                                                                         
  +--------+-------------+------+-----+---------+----------------+                                                                                                        
  | Field  | Type        | Null | Key | Default | Extra          |                                                                                                        
  +--------+-------------+------+-----+---------+----------------+                                                                                                        
  | rollno | bigint(20)  | NO   | PRI | NULL    | auto_increment |                                                                                                        
  | name   | varchar(40) | NO   |     | NULL    |                |                                                                                                        
  +--------+-------------+------+-----+---------+----------------+                                                                                                        
  2 rows in set (0.39 sec)   
  </code></pre>