Hi Friends. I am facing Microsoft ODBC Driver error at run time in my program. I am using window 7, jdk 7 and Ms Access 2007. I am using "jdbc:odbc:JdbcOdbcDriver". I am giving code and error message below. Please tell me solution of this problem

import java.sql.*;    

public class JdbcDMLEx2
   public static void main(String[] args)


         // load driver

          // define connection
          String url = "jdbc:odbc:personDSN";

          // establish connection

          Connection con = DriverManager.getConnection(url);

            // make query and place ? where values are 
            // to be inserted later

         String sql = "UPDATE persons SET address = ? WHERE name=?";

           // creating statement using connection object
           // and passing sql statement as parameter

             PreparedStatement pStmt = con.prepareStatement(sql);

          // assigning first command line argument value 

             String addVar = args[0];

          // assigning 2nd command line argument value 

            String nameVar = args[1];

          //setting first marked parameter(?)by using setString()
         // method to address

           pStmt.setString(1, addVar);

            //setting second marked parameter(?)by using setString()
         // method to name

          pStmt.setString(2, nameVar);

          //executing prepared statement
           int num = pStmt.executeUpdate();

        //   process the results of query
        // printing number of records affected

         System.out.println(num +"records updated");

         // step8: close the connection

        catch(Exception sqlEx)



      }// end main

  } // end class

Following error is occuring at run time:

[Microsoft][ODBC Microsoft Access Driver] Too few parameters.expected 4.

3 Years
Discussion Span
Last Post by JamesCherrill

Please check if there are invalid columns specified in the update statement. This is generally thrown in such a case.

Edited by newcoder310

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.