Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts

    how do I perform select & insert in one jsp Program.

    Hi Friends,
    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 ,

  2. #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Thanked 163 Times in 160 Posts
    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


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts