File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes problem with inserting data in a same column using prepared statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem with inserting data in a same column using prepared statement" Watch "problem with inserting data in a same column using prepared statement" New topic
Author

problem with inserting data in a same column using prepared statement

smyle khanna
Ranch Hand

Joined: Jan 14, 2004
Posts: 54
hi,
i am having a problem in inserting the data into database,i have 2 insert 4 rows into a column n every thing the last row overwrites the rest n only the last row is displayed in the database
the code is blow,plz help me slove this problem...
the opt1,opt2,opt3 are over written by opt4 n only opt4 is there is the database
thanks in advance...
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
There is nothing abnormal happening here I believe.
You are making only one insert and hence one row is getting inserted.
Only opt4 is getting inserted only because of this line :
pstat1.setString(2,opt4);
Replace opt4 with opt3, then only a row with opt3 will appear.
Make 4 inserts (instead of one) in order to insert 4 rows.
You may also go for a batch insert.
[ March 16, 2004: Message edited by: Varun Khanna ]

- Varun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with inserting data in a same column using prepared statement
 
Similar Threads
problems with onkeypress event and select element
After UPDATE Statement, Null Value is fetched
Servlet Displays Old DB Entries
Dependant checkboxes
Problem with addBatch ....