Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 35
Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this ⇒ UseCodeTags. Thanks.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic