Insert Into Database : JSP


I want to insert recort in to my Access database through a .jsp form.
How can I do it...
My code for processing database Query is as follows:


=============================================================

<%@ page import="java.sql.*" %>
<%@ page language="java" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.util.*" %>

<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String queryText = null;
%>

<%
queryText = "insert into Emp values("" + request.getParameter("Ename") + "","" + request.getParameter("Job") + "","" + request.getParameter("Sal") + "");";

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:myDB","","");
stmt = conn.createStatement();
rs = stmt.executeQuery(queryText);
}

catch(Exception e) {
out.println("Error.."+e);
}

%>
=============================================================



Which is giving me some error:

"Error..java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3. "

can anybody help me out?

thanx
r_patel



Comments

  • : I want to insert recort in to my Access database through a .jsp form.
    : How can I do it...
    : My code for processing database Query is as follows:

    Your Mistake: You r passing null strings for uid,pwd. While accessing Access DB using JSP or Servlets do not pass uid,pwd in the below instr
    conn = DriverManager.getConnection("jdbc:odbc:myDB","","");


    Correct Instruction:

    conn = DriverManager.getConnection("jdbc:odbc:myDB");

    rest of ur program is correct and is not going to change



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion