File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected" Watch "java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected" New topic
Author

java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected

wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
hi,
I executed such jsp as follows,but it throws error in this sentence:int i = stmt.executeUpdate(sql1);
the details of the error:
java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected

please give me help! Thanks!

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

Hi wu daly,
Welcome to JavaRanch
You must be having numeric fields in the table but you are using all String variables to pass data in the update statement ?
And please use code tags when posting code, unformatted code is difficult to read.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

And you should avoid using JDBC code in JSPs. Move them to Java class(es).
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
thanks,Vijitha Kumara.
According to the error provided by tomcat server,executeQuery() returns a int value,but now it returns a String value.I've checked this jsp for times,but i still cannot find where the mistake is.
by the way ,how to use code tags when posting code?i come to this forum for the first time.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

wu daly wrote:how to use code tags when posting code?i come to this forum for the first time.


when you post your query ,just check for the "Code" button on top of the text Area(where you are typing the letters)
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
to seetharaman venkatasamy: i got it,thank you!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

wu daly wrote:According to the error provided by tomcat server,executeQuery() returns a int value,but now it returns a String value.


No I mean in your update SQL statement, check with the table (extract.tb_data_source) whether you have any numeric fields in there or post the datatypes used for the fields of that table. BTW executeUpdate returns an int.
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7


Please help!Thanks!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

And now you are seems to having a different error in the JSP. Were you able to resolve the previous error ? What changes you did to the page ? We should see the source then.
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
The main body of the jsp is on top of the page.Just now,i ran it on server,it still failed.
i have copy the mistake given by tomcat server to the page.
Please help me solve the problem.Thank you very much.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575



your are using only one stmt for both DDL and DML queries
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
when i define two Statement,it seems there is the same exception.



Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

wu daly wrote:The main body of the jsp is on top of the page.Just now,i ran it on server,it still failed.
i have copy the mistake given by tomcat server to the page. Please help me solve the problem.Thank you very much.


You have few problems in the page. You are not handling the checked exceptions of JDBC code. You need try catch blocks around that code. I suggest you go through JDBC Tutorial to get those correct.
wu daly
Greenhorn

Joined: Aug 21, 2009
Posts: 7
Thanks!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Ever heard of SQL injection attacks? If not, please read up on it, or your data will be destroyed. If so, I can't fathom why you're building the query like this.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected