1

I am using jdbc connectivity over ms access database and here is my code

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ExcelConnectivity
{
public static void main(String[] args) 
{
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:db");
        String query="update validation set validation.rackid=rack.rackid where rack.bookid=validation.bookid";
        PreparedStatement ps=con.prepareStatement(query);
        ps.executeUpdate();
        System.out.println("doneeeeeeeeeeeeeeeeeeeeee");
    }
    catch(SQLException | ClassNotFoundException e)
    {
        e.printStackTrace();
    }
}
}

now the database is as follow

this is rack table this is validation table

now the error occurring as [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

I have checked the table name in database and jdbc code, checked connection

any anyone help me in error

Stark
  • 481
  • 1
  • 9
  • 31

1 Answers1

0

The query you have used is incorrect, it has nothing to do with the connectivity or connection. The error is trying to convey that you are using parameters in your query but not supplying the values at the execution.

update validation set validation.rackid=rack.rackid where rack.bookid=validation.bookid

where would it pick the rack values from ?

Akash Yadav
  • 2,411
  • 20
  • 32