Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-17-2009, 01:35 PM #1
- Join Date
- Mar 2009
- Thanked 0 Times in 0 Posts
how do I perform select & insert in one jsp Program.
How do i do the insert operation after select query at same jsp program.
Here is the code which is running successfully for select stmt.
<% Connection connection = DriverManager.getConnection("jdbc:odbc:emaildb", "", ""); Statement statement = connection.createStatement(); ResultSet resultset = statement.executeQuery("select CompanyName as CN, sum(ForQtr)as Tota from Imports where CompanyName = '"+Cname+"' group by CompanyName") ;%> <% String CompName=resultset.getString("CN");%> <%float AB=resultset.getFloat("Tota");%>
Now , after some calculations how do I continue to insert data into db inthe same table within this same jsp program.
advance thanks ,
03-20-2009, 06:27 PM #2
the connection object is not restricted to allow the creation of only a single statement...you can create as many as you want as long as the connection is not closed...so, simply create a new prepared statement from the connection that you already have...and don't forget to close the all the resultsets, prepared statements and connections
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow