• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

number format exception..

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic