aspose file tools*
The moose likes JDBC 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
Bookmark "Problem inserting into DB in a JSP" Watch "Problem inserting into DB in a JSP" New topic
Author

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
Greenhorn

Joined: Jul 30, 2001
Posts: 10
1.
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? :]
HTH;
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

what is the offending SQL/DML statement that throws the exception?
Jamie
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:
statementRef.executeUpdate("commit");
trying to commit update using the statement above which is absolutely wrong.
The right way is:
connectionRef.commit();
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: http://aspose.com/file-tools
 
subject: Problem inserting into DB in a JSP