Java &引用;ORA-01008:并非所有变量都已绑定”;

Java &引用;ORA-01008:并非所有变量都已绑定”;,java,oracle,Java,Oracle,我使用这段代码简单地显示任意随机选择的id的数据,但是这个错误正在发生。我看到了关于这个错误的各种帖子,但是我没有看到我的程序的任何结果,请告诉我是什么问题。 我正在使用以下代码 public class Demo { public static void main(String[] args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverMana

我使用这段代码简单地显示任意随机选择的id的数据,但是这个错误正在发生。我看到了关于这个错误的各种帖子,但是我没有看到我的程序的任何结果,请告诉我是什么问题。 我正在使用以下代码

public class Demo {
public static void main(String[] args) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:StudentInfo_Oracle","System","Aadi@123");

    Scanner s = new Scanner(System.in);
    String disq = "Select * from Sample where Id = ?";
    System.out.println("Enter id number which data want to display: ");
    int id = s.nextInt();
    PreparedStatement dis = con.prepareStatement(disq);
    dis.execute();
    ResultSet rs = dis.getResultSet();
    while (rs.next()) {
        System.out.println(rs.getInt(1));
        System.out.println(rs.getString(2));
    }
}

}

在准备语句后设置
的值?

PreparedStatement dis = con.prepareStatement(disq);
dis.setInt(1,id);

嗯,您没有绑定您拥有的唯一变量,因此。。。。似乎很清楚出了什么问题?您忘了绑定id的值。您必须在
disq
中设置参数。id上没有设置数据,因为该值是由用户在rum时间设置的。
id
是String还是int?很抱歉键入错误