• 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

Problem inserting into DB in a JSP

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic