aspose file tools*
The moose likes JDBC and the fly likes Inserting constant values but not  form values on html form on web using tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Inserting constant values but not  form values on html form on web using tomcat " Watch "Inserting constant values but not  form values on html form on web using tomcat " New topic
Author

Inserting constant values but not form values on html form on web using tomcat

Ghazala Islam
Ranch Hand

Joined: Nov 22, 2000
Posts: 73
Following is the piece of code which is working fine
and inserting values in ms access database when I give
values in quotes ( shown in code as commemted),but
when I try to insert form values it throws sqlexception.
Connection and PreparedStatement variables are defined
at class level as pst and c, and c.setAutoCommit(false)
is set at the begining of code.
When I display the sql with out.println(sql) it gives
correct insert statement with all form values but
not inserting.Please guide.
try {
sql = "insert into people " +
" values(" + request.getParameter("name") +
"," + request.getParameter("address") +
"," + request.getParameter("aqual") +
"," + request.getParameter("tqual") +
"," + request.getParameter("loc") + ")" ;
//" values('aaa','aaa','aaa','aaa','aaa')" ;

pst = c.prepareStatement(sql);
pst.executeUpdate();

c.commit();
c.setAutoCommit(true);
A Agrawal
Ranch Hand

Joined: Jul 13, 2001
Posts: 41
use single quotes for Strings values.
Plz try with this code and let me know If you still face any problem.
sql = "insert into people " +
" values('" + request.getParameter("name") +
"','" + request.getParameter("address") +
"','" + request.getParameter("aqual") +
"','" + request.getParameter("tqual") +
"','" + request.getParameter("loc") + "')" ;
//" values('aaa','aaa','aaa','aaa','aaa')" ;

------------------
Amit Agrawal,
New Delhi, India.


Amit Agrawal,<BR>New Delhi, India.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inserting constant values but not form values on html form on web using tomcat