Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: help with these

  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    82
    Thanks
    10
    Thanked 0 Times in 0 Posts

    help with these

    <html>
    <body>

    <%@ page import="java.sql.*"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.util.*"%>
    <%
    try {
    Connection con;
    Statement stmt;
    ResultSet rs;
    String broker = request.getParameter("broker");
    String stock = request.getParameter("stock");
    String value = request.getParameter("value");
    String qty = request.getParameter("qty");

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbcdbc:sherwin","","");
    stmt = con.createStatement();

    rs = stmt.executeQuery("INSERT INTO stocks (broker,stock,value,qty) VALUES ('"+broker+"','"+stock+"','"+value+"','"+qty+"'));

    response.sendRedirect("main.jsp");
    con.close();
    } catch (Exception e){
    System.out.println("SQL Exception : " + e.getMessage());
    }
    %>

    </body>
    </html>

    whats wrong with that?

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by sher_amf View Post
    Code:
    rs = stmt.executeQuery("INSERT INTO stocks (broker,stock,value,qty) VALUES ('"+broker+"','"+stock+"','"+value+"','"+qty+"'));
    whats wrong with that?
    u've not closed the final double-quote !!
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

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