Solved

Insert statement in Servlet JDBC program

Posted on 2004-03-21
3
4,605 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
3 Comments
 
LVL 4

Accepted Solution

by:
barthdev earned 75 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now