File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
rumana amin
Ranch Hand
Posts: 35
Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without code, no one can even guess. Please be sure to use code tags when posting code.
 
rumana amin
Ranch Hand
Posts: 35
Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 150
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will not look at unformatted code. Please edit your code to use code tags as already instructed.
 
rumana amin
Ranch Hand
Posts: 35
Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this ⇒ UseCodeTags. Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic