Java JDBC NumberFormatException: For input string

Stack Trace:
Exception in thread "main" java.lang.NumberFormatException: For input string: "Mike"
 at sun.misc.FloatingDecimal.readJavaFormatString(
 at sun.misc.FloatingDecimal.parseDouble(
 at java.lang.Double.parseDouble(
 at com.mysql.cj.protocol.a.MysqlTextValueDecoder.getDouble(
 at com.mysql.cj.result.AbstractNumericValueFactory.createFromBytes(
 at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeByteArray(
 at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(
 at Sample.main(

This Exception occurs when you are trying to iterate over the ResultSet Object and making use of the getInt() method instead of getString(), the column in the Database table is a String and not a Number!


Replace getInt() with getString()

Java.lang.NumberFormatException- For input string

Have Questions? Post them here!
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.