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.

Recommended Answers

All 2 Replies

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).

Take a look at the SQL insert syntax and compare it with yours. Do you see anything wrong with it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.