wood burning stoves 2.0*
The moose likes JSP and the fly likes showing error  in jsp that data type value cannot convert to numeric Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "showing error  in jsp that data type value cannot convert to numeric" Watch "showing error  in jsp that data type value cannot convert to numeric" New topic
Author

showing error in jsp that data type value cannot convert to numeric

rumana amin
Ranch Hand

Joined: May 02, 2010
Posts: 35

hi friends
i'm founding the error again n again while running a jsp page .it shows data type value cannot converted to numeric value.i'v made a table in sql server which hold (at_code,at_na,o_bal,m_bal,r_int)which is in the form of varchar n numeric.but why it is showing this error?please help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Without code, no one can even guess. Please be sure to use code tags when posting code.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
rumana amin
Ranch Hand

Joined: May 02, 2010
Posts: 35

hi friends
this is the code i have written for jsp server page( accounts.jsp) for client page called (account.jsp).but when i run this account.jsp on internet explorer to save some data on this page and click on submit button then it shows the message that EXCEPTION REPORT ---data type varchar cannot converted to numeric value.please solve the error.thank you.



<%@ page language="java" import="java.sql.*" %>
<html>
<head>
<title>net banking</title>
</head>
<body>
<%!
String at_code,at_na,o_bal,m_bal,r_int,bsub,bfi,bpress;
Connection scon;
Statement stmt;
public void connect2db(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException cnfe){
System.out.println("class not found"+cnfe);
}
try{
scon=DriverManager.getConnection("Jdbc:Odbc:LocalServer","sa","");
}
catch(SQLException sql){
System.out.println("driver not load"+sql);
}
try{
stmt=scon.createStatement();
}
catch(SQLException sq){
System.out.println("create connection"+sq);
}
}
%>
<%
connect2db();
at_code=request.getParameter("txtaccounttypecode");
at_na=request.getParameter("txtaccounttypename");
o_bal=request.getParameter("txtopeningbal");
m_bal=request.getParameter("txtminbal");
r_int=request.getParameter("txtrateofintrest");
bsub=request.getParameter("btnsubmit");
bfi=request.getParameter("btnfi");
if(bsub!=null)
bpress="submit";
if(bfi!=null)
bpress="find";
if (bpress.equals("submit")){
stmt.executeUpdate("insert into ipnb1accountt values('"+at_code+"','"+at_na+"','"+o_bal+"','"+m_bal+"','"+r_int+"')");
out.println("Successfully Registered");
}
else
if(bpress.equals("find")){
out.println("<script language=\"javascript\">");
out.println("window.location=\"accountfind.jsp\"");
out.println("</script>");
}
%>
</body>
</html>
Pravin Shirke
Ranch Hand

Joined: Apr 05, 2008
Posts: 150

Hi rumana,
please use code tags.

and for your error, try using prepareStatment and use setString or setInt according to your column type. i think this will suffice.

good luck


[Vipassana] - It is seeing the reality as it is, And not as you want it to be.!!!
SCJP1.5.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

I will not look at unformatted code. Please edit your code to use code tags as already instructed.
rumana amin
Ranch Hand

Joined: May 02, 2010
Posts: 35

hi friends
i cannot understand what is code tag ?as i have already specify the whole program.actually i'm not that proficient in jsp programming.it is my first project in jsp.so kindly guide me .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please read this ⇒ UseCodeTags. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

And is this a legacy JSP page? If it's new code, it should follow modern standards and have no Java code in the JSP. And especially not database access code!

You might want to read this article
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: showing error in jsp that data type value cannot convert to numeric