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

  • SEARCH
  • Home
  • 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 6853667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:32:21+00:00 2026-05-27T01:32:21+00:00

My JAVA script consists of 2 JAVA classes: RMS , queryRMS In the RMS

  • 0

My JAVA script consists of 2 JAVA classes: RMS, queryRMS
In the RMS class I call the method in the queryRMS class

RMS Java Class (I left out the start execution part, below is just the method)

    for (int i = 1; i <= itemCount; i++) {
        GlobalVariables.numberRow = i;
        JavaDatapool.settings();

        String item = queryRPM.connectDB_Multi(configFile,"SELECT ITEM FROM ORDSKU WHERE ORDER_NO  = '" + orderNo + "' ORDER BY ITEM ASC",i);
        JavaDatapool.writeXLS("item",item,GlobalVariables.sheetXLS);
        sleep(1);

    }

queryRMS JAVA class

public static String connectDB_Multi(String configFile, String query, int i) throws FileNotFoundException, IOException, SQLException, ClassNotFoundException{
    Properties p = new Properties();
    p.load(new FileInputStream(configFile));

    String serverName = (p.getProperty("RMS_DBServerName"));
    String portNumber = (p.getProperty("RMS_PortNumber"));
    String sid = (p.getProperty("RMS_SID"));
    String url = "jdbc:oracle:thin:@//" + serverName + ":" + portNumber + "/" + sid;
    String username = (p.getProperty("RMS_Username"));
    String password = (p.getProperty("RMS_Password"));
    //  jdbc:oracle:thin:@//localhost:1521/orcl

    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection = DriverManager.getConnection(url,username,password);     
    String setr = null;
    try {      
        Statement stmt = connection.createStatement();

        try {ResultSet rset = stmt.executeQuery(query);
            try {
                while(rset.absolute(i))   
                    setr = rset.getString(1);
                    return setr;  
            }        
            finally {
                try { rset.close(); 
                } 
                catch (Exception ignore) {}

            }
        } 
        finally {
            try { stmt.close(); 
            } 
            catch (Exception ignore) {}
        }
    } 
    finally {
        try { connection.close(); 
        } 
        catch (Exception ignore) {}

    }
}

So what it does is call the connectDB_multi class and then returns the String where the next part is saving it inside an Excel worksheet.

The loop should return all rows, one at a time and then save it inside the Excel worksheet.

In the second time in loop the query is faulted, eventhough the query should return 1 column consisting of 2 rows.

the original contained the part while(rset.next()) instead of while(rset.absolute(i))
but next only return the first row everytime. so the script works when only one column and row is retrieved from the Database.

  • 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-05-27T01:32:22+00:00Added an answer on May 27, 2026 at 1:32 am

    Your logic looks a bit messed up.

    Look at the first loop you posted. You are, effectivly, executing:

    SELECT ITEM FROM ORDSKU WHERE ORDER_NO = '" + orderNo + "' ORDER BY ITEM ASC

    itemCount number of times. Each time you execute it, you are attempting to access the n:th row, n being loop counter. Do you see a problem there? How do you know that the query will return itemCount number of rows? Because if it doesn’t, it will fail since you are attempting to access a row that doesn’t exist.

    What I suspect you WANT to do is something like this

    Statement stmt = connection.createStatement();
    ResultSet rset = stmt.executeQuery(query);
    while(rset.next()) {
        JavaDatapool.writeXLS("item",rset.getString(1),GlobalVariables.sheetXLS);
    }
    

    You should also seriously consider using some form of connection pooling to avoid having to re-open new connections all the time as that is a pretty time-consuming operation.

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

Sidebar

Related Questions

I've just implemented build and deploy process which consists of java files, ant script
java script to alert the mutile option selected ..in <select> HTMl tag. and tag
I need a java script function that converts the document object of the current
I have a java script function that i have called on body load mousemove()
I have java script code to set some of the properties of ajax controls.
How to embed java-script in the java code written in gwt.Please give me an
The following java-script is working fine (Jquery) $(document).ready(function(){ $('#c_area').load($('.m_top:first').attr('href')) }); $('.m_top').click( function(){ $(#myDiv).html('<img src=images/loading.gif
I am using Java Script MVC framework for building a Web Application.. Now i
I am wondering if anyone knows a java script library that would add a
We can easily alert anything in java script. Is it possible to get this

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.