| Author |
number format exception..
|
jyotsana dang
Ranch Hand
Joined: Sep 26, 2003
Posts: 135
|
|
this jsp code is giving a number format exception.. i have this code that selects the previous values and shows them on the page.. <% Connection con=null; java.sql.Statement stmt=null; ResultSet rs=null; boolean y=false; int i; String xy=(String)session.getAttribute("y"); System.out.println("select Desg,Email_id,EPABX,Home_Page from login where user_login='"+xy+"'"); String Desg=""; String Email_id=""; String address=""; String Home_Page=""; int EPABX=0; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc dbc:mech_iit"); stmt=con.createStatement(); rs=stmt.executeQuery("select Desg,Email_id,EPABX,Home_Page from login where user_login='"+xy+"'"); if(rs.next()) { Desg=rs.getString("Desg"); Email_id=rs.getString("Email_id"); EPABX=rs.getInt("EPABX"); Home_Page=rs.getString("Home_Page"); } } catch(Exception e) { System.out.println("exception in block"+e); } System.out.println("Desg="+Desg); System.out.println("Email_id="+Email_id); System.out.println("EPABX="+EPABX); System.out.println("Home_Page="+Home_Page); %> This page calls the profile_update page: try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc dbc:mech_iit"); stmt=con.createStatement(); String Desg=request.getParameter("Desg"); String Email_id=request.getParameter("Email_id"); String Home_Page=request.getParameter("Home_Page"); int EPABX=Integer.parseInt(request.getParameter("EPABX")); String xy=(String)session.getAttribute("y"); out.println("update login set Desg='"+Desg+"',Email_id='"+Email_id+"',Home_Page='"+Home_Page+"',EPABX="+EPABX+" where user_login='"+xy+"'"); rs=stmt.executeQuery("update login set Desg='"+Desg+"',Email_id='"+Email_id+"',Home_Page='"+Home_Page+"',EPABX="+EPABX+" where user_login='"+xy+"'"); System.out.print("Desg"+Desg); System.out.print("Email_id"+Email_id); System.out.print("Home_Page"+Home_Page); System.out.print("EPABX"+EPABX); } catch(Exception e) { System.out.println(e); } %>
|
 |
Varun Khanna
Ranch Hand
Joined: May 30, 2002
Posts: 1400
|
|
Your database name suggests that you are in Mechanical branch of some engineering institute in India. Am I right? So is this a project/home work btw... you need to indentify the line where this error is coming. Probably you are assigning a number to a String. [ March 18, 2004: Message edited by: Varun Khanna ] [ March 18, 2004: Message edited by: Varun Khanna ]
|
- Varun
|
 |
Mani Ram
Ranch Hand
Joined: Mar 11, 2002
Posts: 1140
|
|
Check what is the content of EPABX. You might get a NumberFormatException if the EPABX is i) not a valid number ii) an empty String iii) null [ March 18, 2004: Message edited by: Mani Ram ]
|
Mani
Quaerendo Invenietis
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56214
|
|
|
Moving to the Java in General(intermediate) forum.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Gowrishankar Mudaliar
Ranch Hand
Joined: Oct 20, 2001
Posts: 39
|
|
Try this.. int EPABX= request.getParameter("EPABX") != null ? Inetger.parseInt(request.getParameter("EPABX").trim()) : 0; This assumes that you have a valid integer value in the EPABX field.
|
 |
jyotsana dang
Ranch Hand
Joined: Sep 26, 2003
Posts: 135
|
|
hi.. EPABX is a numeric value.. i tried the above solutions..but now tomcat is throwing the foll. exception.. java.sql.SQLException: No ResultSet was produced
|
 |
 |
|
|
subject: number format exception..
|
|
|