import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
 
/**
 *
 * @author Arvind
 */
public class dao {
 
    Connection con;
    PreparedStatement stat;
    ResultSet rs;
    String insert = "insert into milk(id,P_date,Quantity,rate,Milk_type,company) values(?,?,?,?,?,?)";
 
    public int insert_record(data mk) throws ClassNotFoundException, SQLException {
        con = getConnection();
        stat = con.prepareStatement(insert);
        int id = objectid();
        stat.setInt(1, id);
        System.out.println("id set" + id);
        System.out.println("date is" + mk.getBought());
        stat.setString(2, mk.getBought());
        System.out.println("bought set" + id);
        stat.setDouble(3, mk.getQuantity());
        System.out.println("quantity set" + id);
        stat.setDouble(4, mk.getRate());
        System.out.println("rate set" + id);
        stat.setString(5, mk.getType());
        System.out.println("type set" + id);
 
        stat.setString(6, mk.getCompany());
        System.out.println("company set" + id);
        int i = stat.executeUpdate();
        return i;
    }
    String get_id = "select id from objectid";
 
    private int objectid() throws ClassNotFoundException, SQLException {
        int i = 0;
        con = getConnection();
        stat = con.prepareStatement(get_id);
        rs = stat.executeQuery();
        while (rs.next()) {
            i = rs.getInt("id");
        }
        update(i);
        return i;
    }
    String update_id = "update objectid set id=?";
 
    private void update(int i) throws ClassNotFoundException, SQLException {
 
        con = getConnection();
        stat = con.prepareStatement(update_id);
        stat.setInt(1, ++i);
 
    }
 
    private Connection getConnection() throws ClassNotFoundException, SQLException {
 
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection conn = DriverManager.getConnection("jdbc:odbc:milk", "milk", "milk");
        return conn;
    }
 
    public java.sql.Date utilToSqlDate(Date da) {
        return new java.sql.Date(da.getTime());
    }
}

this is my class for accessing the Microsoft Access 2007 database!!
and when i try to execute my code i get the following errors
id set1
date is2011-10-21
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.clearParam eter(JdbcOdbcPreparedStatement.java:1022)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setChar(Jd bcOdbcPreparedStatement.java:3056)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setString( JdbcOdbcPreparedStatement.java:765)
at milk.dao.insert_record(dao.java:32)
at milk.Milk.main(Milk.java:33)
Java Result: 1
i googled this but not having luck!!
regards