You can code as follows (using Batch Update requires JDBC 2.x supporting
driver)
// turn off autocommit
con.setAutoCommit(false);
PreparedStatement stmt = con.prepareStatement("INSERT INTO TableName VALUES
(?, ?)");
stmt.setString(1,value1a); // get values from recordset of select statement
stmt.setString(2, value1b);
stmt.addBatch();
stmt.setString(1,value2a);
stmt.setString(2, value2b);
stmt.addBatch();
// submit the batch for execution
int[] updateCounts = stmt.executeBatch();
Hope this will help you.
Cheers,
Sanjay
-----------------------------------------------------------------
Sanjay Kumar,
Software Consultant,
Addcon India Pvt Ltd.
New Delhi.
Emails : [EMAIL PROTECTED]
[EMAIL PROTECTED]
Phones : 6423907,6201330 (Office)
"Keep Smilling. It does increase your face value"
-----------------------------------------------------------------
----- Original Message -----
From: Rathinavel Palaniappan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 12, 2000 9:46 AM
Subject: How to set String values in PreparedStatement?
> hi folks,
>
> Sorry for bit off topic question, but i hope somebody
> can thru light on it!.
>
> I have problem on setting String values in the
> prepared statement.I have a sql statement
> somthing like,
>
> "insert into TableName (Name, Age, ?,?, Sponser_Name,
> Sponser_country) select tbl.Name,tbl.Age,tbl.Address1,
> tbl.Address2, tbl.Sponser_Name,tbl.Sponser_country from
> tbl";
>
> (This is to copy data form one table to another table)
>
> here i want to set the coloumn name at run time by using
> prepareStatement setString. but i am getting exception
> "syntax error in INSERT INTO statement" when execute
> the query.
>
> so how could i set the values using setString? FYI, setString
> of prepareStatement works when the '?' appears in the
> 'where' clause.
>
> thanks for your time,
>
> with regards,
> rathna.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets