0

This is my code.

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Registration Page</title>
    </head>
    <body background= "bg8.jpg" width="1000" height="1000" alt="work1">
     
        <form action="clientlogin.jsp"><table>
                <tr> <td> Company Name</td><td> <input type="text" name="cname" value="" /></td> </tr>
            <tr> <td> Password </td><td><input type="password" name="pwd" value="" /></td> </tr>
            <tr> <td>Location of company </td><td><input type="text" name="location" value="" /></td></tr>
            <tr><td> Company Type</td><td><select name="ctype">
                <option>Banking </option>
                <option>Insurance </option>
                <option>IT </option>
                <option>Marketing-sales</option>
            </select></td></tr><br>
            <tr><td>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<INPUT TYPE="image" SRC="bg2.jpg" HEIGHT="70" WIDTH="80" BORDER="0" ALT="Submit Form">
</td></tr>
            </table>
                <%@page import="java.sql.*"  %>
                <%
                   String cname=request.getParameter("Compname");
                   String pwd=request.getParameter("pwd");
                   String loc=request.getParameter("location");
                   String ctype=request.getParameter("ctype");
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection c= DriverManager.getConnection("Jdbc:Odbc:emp");
                   Statement s= c.createStatement();
                   s.executeUpdate("INSERT Comp_log('comp_name','password','location','ctype') VALUES('"+cname+"','"+pwd+"','"+loc+"','"+ctype+"')" );

               %>
        </form>
    </body>
</html>

I got this error.

HTTP Status 500 - 
type Exception report
message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

root cause

How to clear this?


java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ~s.o.s~
0

Do not use scriptlets in JSP, use, at the very least, a servlet.

Do not cobble together statements like that, use a PreparedStatement.

Use a Connection Pool (see the documentation for your web container).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.