-1
String get_date = check_in_date.getText();
String get_customer_no = customer_no.getText();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rst = null;
try{
String driver ="com.mysql.jdbc.Driver";
String url ="jdbc:mysql://localhost:3306/hotel";
String userid ="root";
String password ="tushar11";
Class.forName(driver);
conn = DriverManager.getConnection(url,userid,password);
pstmt = conn.prepareStatement("select occupantdetails.customer_name,
hoteldetails.service_detail, hoteldetails.cab_no from
occupantdetails JOIN hoteldetails ON
occupantdetails.customer_no=hoteldetails.customer_no");
pstmt.setString(1, get_customer_no);
rst = pstmt.executeQuery();
while(rst.next()){
txt_customer_name.setText(rst.getString("customer_name"));
txt_room_no.setText(rst.getString("service_detail"));
txt_cab_no.setText(rst.getString("cab_no"));
}
}
我對此很陌生。當我提取細節時,它顯示參數錯誤,我無法解決這個問題。我想我已經寫了正確的查詢,並可能在Java代碼中出現錯誤。從表格中讀取數據時顯示此錯誤參數索引超出範圍(1>參數數量)
您的查詢沒有任何參數。但你仍然通過一個。因此,無論是將參數添加到查詢還是不添加參數。 –