Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4647
  • Last Modified:

Insert statement in Servlet JDBC program

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
aayush123
Asked:
aayush123
1 Solution
 
barthdevCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now