Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem inserting into DB in a JSP

 
Gabriel Fox
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the offending SQL/DML statement that throws the exception?
Jamie
 
Gabriel Fox
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!