Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert statement in Servlet JDBC program

Posted on 2004-03-21
3
Medium Priority
?
4,639 Views
Last Modified: 2012-08-14
Hi,
I am new to oracle 9i on Windows.I have written a  Servlet program which uses  JDBC for insertion data in table maintained in Oralce Database.The query statements (like SELECT )  are running fine.But I encountered problem in Insert Statement  in table created from command prompt. My code statement is:-
HttpServletRequest req;String Name,Email;
Connection c;

Name=req.getParameter("Name");
Email=req.getParameter("Email");

Statement s=c.createStatement();
s.executeUpdate("INSERT INTO Table VALUES('"+Name+"','"+Email+"');");

I am getting Email and Name variable in browser but insertion is not taking place.
Insertion query is I think the syntax of query is correct.
0
Comment
Question by:aayush123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
barthdev earned 300 total points
ID: 10644093
If queries are working, I'll assume that your servlet has a valid Connection. (You do use an initialized Connection object in this method, yes?)

I notice four things that might be easily overlooked by someone that is new to database programming.

1) Is the table name actually "TABLE"?
2) Does the table only have two fields?
3) Is the table in the same schema as your Connection object?

To continue with debugging:

1) What value is returned from the executeUpdate?
2) Or, what SQLException is thrown?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question