aspose file tools*
The moose likes Servlets and the fly likes inserting values in database.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "inserting values in database...." Watch "inserting values in database...." New topic
Author

inserting values in database....

Mahajan Bhupendra
Ranch Hand

Joined: Dec 01, 2000
Posts: 118
hi ,
i got stucked with sql-servlet combination...
i have worked comfortably with select statements..
i tried one insert statement and i got the problem
rs=st.executeQuery("insert into Result (Name,Roll_no) values('"+req.getParameter("name")+"','"+req.getParameter("roll_no")+"');");

this is the actual statement and it inserts values in database
also but throws an exception..
java.sql.SQLException: No ResultSet was produced
what do i do so that i won't get the exception?
also if i just want to check that if some value is there in
database or not e.g. user name and poassword, which sql
statement should i use?
Thanx for ur helping hand...
bhupendra


<B>Bhupendra Mahajan</B>
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
The insert statement does not create a result set, unlike a select statement. I think you may want to use the executeUpdate() methoed rather than the executeQuery() method. executeUpdate() will return an int representing the number of rows affected.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting values in database....
 
Similar Threads
JDBC with oracle
doubt regarding default values
Code error
how to write into excel sheet
java.sql.SQLException: General error; is occuring