简体   繁体   中英

How to Run Query on Long number

Hello everyone i am trying to run a simple query on a long number i have tried but still returns me id type is long integer. I am getting all the data a jTable and the 1st column is of id when i ever click on the row it always gives me this exception and i have got the correct value from table when printed in console

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

My code is :

int row = recordsTable.getSelectedRow();
    String tableValue = (recordsTable.getModel().getValueAt(row, 0).toString());

    String qry = "Select * from records where id ='" + Long.parseLong(tableValue) + "'";
    try {
        db.setStmt((Statement) db.getCon().createStatement());
        ResultSet rs = ((java.sql.Statement) db.getStmt()).executeQuery(qry);
        if (rs.next()) {

            id=rs.getLong("id");
            idTextField.setText(Long.toString(id));


            customerCode = rs.getString("customer_code");
            custCodeTextField.setText(customerCode);

            firstName = rs.getString("first_name");
            firstTextField.setText(firstName);

            lastName = rs.getString("last_name");
            lastTextField.setText(lastName);

            customerContact = rs.getString("customer_mobile");
            custMobTextField.setText(customerContact);

            customerAddress = rs.getString("customer_address");
            custAddressTextField.setText(customerAddress);

            fillComboBox();
            area=rs.getString("area");
            areaComboBox.setSelectedItem(area);

            payment_this_month = rs.getInt("payment");
            paymentTextField.setText(Integer.toString(payment_this_month));

            duePayment = rs.getInt("balance");
            balTextField.setText(Integer.toString(duePayment));

            java.util.Date dateSet = rs.getDate("bill_issued_on");

            billTextField.setText(dateSet.toString());

            connectionStatus = rs.getString("connection_status");
            jComboBox2.setSelectedItem(connectionStatus);

删除'" + Long.parseLong(tableValue) + "'"周围的单引号

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM