File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Problem inserting into DB in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem inserting into DB in a JSP" Watch "Problem inserting into DB in a JSP" New topic

Problem inserting into DB in a JSP

Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170

Hi Pals, i have a class which contains my SQL strings for select
and insert....
This class is used in my JSP to run a query / insert via a Database+JDBC class.My problems are:
1.after successfully inserting some records into my oracle db (table) and did a select to confirm the insert ,i still get this error on my Tomcat window:
java.sql.SQLException: ORA-00900:invalid SQL statement
2.If i have a field as NUMBER on my database table .What effect
does this have : inserting a Java type of "898"(a stringified number) in my insert statement as long as i donot have it in
single quotes in my VALUES(.....) clause
please help;
Kenneth Reising

Joined: Jul 30, 2001
Posts: 10
Slightly confused:
Are you getting the error from the Insert or on the Select?
Remember that an Insert does not return a ResultSet Object, and I've gotten this error when I have tried to get one from an Insert/Update.
You can however, get the number of effected rows by using something like this:
stmt = Connection.createStatement();
rowsAffected = stmt.executeUpdate(YourSQLQuery);

2. There shouldnt be a problem with it becauase by the time the statement hit Oracle, the String has been parsed already.
What happens when you try? :]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

what is the offending SQL/DML statement that throws the exception?
Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Big Cheers Kenneth & Jamie,
1.Ora 900 : Invalid SQL Statement.I did something
stupid,i was doing this:
trying to commit update using the statement above which is absolutely wrong.
The right way is:
since commit()is a method of the connection object.
2.inserting "2323" using
executeUpdate("sqlString") worked fine no errors
Thaks guys.
I agree. Here's the link:
subject: Problem inserting into DB in a JSP
jQuery in Action, 3rd edition