Results 1 to 2 of 2
  1. #1
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default Not able to to insert values in ms-access database

    In below code t1,t2,t3 respectivily three fields of form t1 for name,t2 e_no an t3 for password
    code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class RegForm extends HttpServlet{
    public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException{
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    String n=req.getParameter("t1");
    String e=req.getParameter("t2");
    String p=req.getParameter("t3");
    //Statement st= null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:school" ,"","");
    PreparedStatement st=con.prepareStatement("insert into student values + (?,?,?)");
    st.clearParameters();
    st.setString(1,n);
    st.setInt(2,Integer.parseInt(e));
    st.setString(3,p);
    st.executeUpdate();

    con.close();
    }catch(Exception ex){
    ex.printStackTrace(System.out);
    }
    }
    }

    I am not able to insert values in db by above code.
    db fields are
    name data-type text
    e_no data-type number
    pass data-type text

    Please provide any pointer

  2. #2
    kkji is offline Member
    Join Date
    Aug 2011
    Posts
    54
    Rep Power
    0

    Default Re: Not able to to insert values in ms-access database

    any help please.

Similar Threads

  1. Replies: 2
    Last Post: 09-27-2011, 01:38 AM
  2. Replies: 2
    Last Post: 09-25-2011, 11:31 AM
  3. insert the combination values
    By srikanthk035 in forum JDBC
    Replies: 2
    Last Post: 05-17-2011, 03:01 PM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. how to fetch 20,000 records from excel sheet & insert into access database using Java
    By santosh_tamse in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-22-2009, 10:24 AM

Posting Permissions

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