Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9059795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:03:50+00:00 2026-06-16T15:03:50+00:00

private void btgetinvActionPerformed(java.awt.event.ActionEvent evt) { //JOptionPane.showMessageDialog(null, REMITTANCE ID IS VALID!); try { DBUtil util

  • 0
 private void btgetinvActionPerformed(java.awt.event.ActionEvent evt) {
        //JOptionPane.showMessageDialog(null, "REMITTANCE ID IS VALID!");
        try {
            DBUtil util = new DBUtil();
            Connection con = util.getConnection();
            PreparedStatement stmt = con.prepareStatement("select bk_det.rm_id from bk_det WHERE dbo.bk_det.rm_id = ?");
            ResultSet rs;
            String rm = tf_rmid.getText().trim();
            stmt.setInt(1, Integer.parseInt(rm));
            rs = stmt.executeQuery();
            while (rs.next()) {
                int i = Integer.parseInt(rs.getString("box_no"));
                tfbrname.setText(rs.getString(i));
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());

        }
    }

I am actually trying to search value from my database table called dbo.bk_det. I am taking the value of WHERE from my textfield tf_rmid. Everything goes on well without error but once i insert the rm_id and click on button btgetinv it says 123 which is my rm_id is out of range cant understand where the error is and what is the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:03:51+00:00Added an answer on June 16, 2026 at 3:03 pm

    The problem is with the following statements:

    int i = Integer.parseInt(rs.getString("box_no"));
    tfbrname.setText(rs.getString(i));
    

    The first statement won’t work the way you want because there’s no column named “box_no” in the select clause. It will throw an exception. Let’s assume you change the code to have box_no in the select clause. Then, the second statement will try to retrieve the nth column where the column is the value of box_no. I think you just want:

    tfbrname.setText(rs.getString("box_no"));
    

    Again, the above only will work if your SELECT statement includes box_no in the field list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void buttonAddJobActionPerformed(java.awt.event.ActionEvent evt) { try { retrieveID(); String sqlStm = INSERT INTO Job
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int count = jSlider1.getValue(); int delay = jSlider2.getValue(); int
private void pushButtonActionPerformed(java.awt.event.ActionEvent evt) { final int c=0; final JDialog d=new JDialog(); JLabel l=new
private void cbdmnstatItemStateChanged(java.awt.event.ItemEvent evt) { if(evt.getsource()==getSelectedItem){ tf1.setFocus(true); } }
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { //cant capture my TAB? System.out.print(evt.getKeyChar()); } What is the
private void CopyAssets2() { AssetManager assetManager = getAssets(); String[] files = null; try {
private void EnsureCurrentlyValid() { //I'm valid if IDataErrorInfo.this[] returns null for every property var
private void copyMB() { AssetManager assetManager = this.getResources().getAssets(); String[] files = null; try {
private void SaveAsPicture_Click(object sender, RoutedEventArgs e) { WriteableBitmap bmp = new WriteableBitmap(MyUIElement, null); var
private void btnMiles_Click(object sender, EventArgs e) { try { int milesless200 = int.Parse(txtMiles.Text); int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.