This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing Input GUI  RSS feed

 
jonas okwara
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please I will appreciate if someone tell me what I am doing wrong.
I have a swing input Gui through which I insert data into a mysql database. It allow me to insert only once and spews out error message when
i attempt to insert subsequent data into the database. Unless I close the
Gui after inserting the data and lauch it back again.

I am frustrated at this point. The error message is below.

thanks
jonas

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: " 36"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
at P_package.DialogInterFace.addRecordActionEvent(DialogInterFace.java:160)
at P_package.DialogInterFace$1.actionPerformed(DialogInterFace.java:93)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It tries to turn the string " 36" (with leading space) into an int, and that won't work.

If you trim() you string first this error shouldn't occur.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's with the space character before the 36 (if that's what it is)? What happens if you remove that?
 
jonas okwara
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for this hint. I am grateful
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!