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 7531579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:12:35+00:00 2026-05-30T05:12:35+00:00

I have a problem i’m trying to read another row in my ResultSet but

  • 0

I have a problem i’m trying to read another row in my ResultSet but dunno why can’t my loop just end at rs.next(). Yes, i got more than 1 rows in tblPracownicy. I check ResultSet content with while(rs.next())system.out.println(rs.getRow(1)) before DO and it look good i got that number of result as much i got rows in tblPracownicy. But in DO loop i didn’t know why it won’t cycle the loop. here is the code:

ResultSet rs2 = stat.executeQuery("select _id, cykl_id, CyklDzien, CyklData, DataZatrudnienia, DataZwolnienia from tblPracownicy");
            //wygeneruj harmonogramy dla pracowników
            long prac_id = rs2.getLong(1);
            int offset;
            Cykl cykl = null;

            do
            { //pracownicy
                //odnajdź i pobierz cykl dla pracownika prac_id
                if (cykl == null || cykl.cykl_id != rs2.getLong(2))
                    for (Cykl c : cykle)
                        if (c.cykl_id == rs2.getLong(2)) 
                        {
                            cykl = c;
                            break;
                        }
                //ustaw offset cyklu na dzień 1.szy
                GregorianCalendar gc_cykl = new GregorianCalendar();
                gc_cykl.setTime(rs2.getDate(4));
                gc_harm = new GregorianCalendar(rok, miesiac-1, 1);
                //uwzględnij startowy dzień cyklu = CyklDzien
                gc_cykl.add(GregorianCalendar.DAY_OF_MONTH, -rs2.getInt(3)+1);
                offset = (int) ((gc_harm.getTimeInMillis() - gc_cykl.getTimeInMillis()) / (3600000*24)) % cykl.dlugosc;
                //przelicz offset na dodatni
                if (offset < 0) offset = cykl.dlugosc + offset;

                GregorianCalendar gc_zatr = new GregorianCalendar(new Integer(rs2.getString(5).substring(0, 4)), new Integer(rs2.getString(5).substring(5, 7)), new Integer(rs2.getString(5).substring(8)));
                GregorianCalendar gc_zwol = null;
                //if (!(rs2.getString(6) == null || rs2.getString(6).equals("")))
                if ((rs2.getString(6) != null && !rs2.getString(6).equals("")))
                {
                    gc_zwol = new GregorianCalendar(new Integer(rs2.getString(6).substring(0, 4)), new Integer(rs2.getString(6).substring(5, 7)), new Integer(rs2.getString(6).substring(8)));
                }
                //definiuj zmiany pracownika na cały miesiąc
                for (int dzien=1; dzien <= max; dzien++)
                { //dni
                    //w dni miesiąca kiedy pracownik nie jest zatrudniony wstawić dni wolne
                    gc_harm.set(rok, miesiac, dzien);
                    if (gc_harm.before(gc_zatr) || (gc_zwol != null && gc_harm.after(gc_zwol)))  //jesli przed zatrudnieniem lub po zwolnieniu
                    {   //wpisz dzien wolny = niekasowalne godziny 'xx - xx' o id = 0
                        stat.executeUpdate("insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                + "values (" + id + ", " + dzien + ", " + prac_id + ", " + 0 + ");");
                    }else{
                        //wpisz zmianę
                        stat.executeUpdate("insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                + "values (" + id + ", " + dzien + ", " + prac_id + ", " + cykl.godziny[offset] + ");");
                    }
                    offset++;
                    if (offset >= cykl.dlugosc) offset = 0;
                }
            }while (rs2.next());
  • 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-30T05:12:37+00:00Added an answer on May 30, 2026 at 5:12 am

    ok problem solved, the two query cause “interference” in working of ResultSet.

    if (gc_harm.before(gc_zatr) || (gc_zwol != null && gc_harm.after(gc_zwol)))  //jesli przed zatrudnieniem lub po zwolnieniu
                    {   //wpisz dzien wolny = niekasowalne godziny 'xx - xx' o id = 0
                        stat.executeUpdate("insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                + "values (" + id + ", " + dzien + ", " + prac_id + ", " + 0 + ");");
                    }else{
                        //wpisz zmianę
                        stat.executeUpdate("insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                + "values (" + id + ", " + dzien + ", " + prac_id + ", " + cykl.godziny[offset] + ");");
                    }
    

    Now i got:

    if (gc_harm.before(gc_zatr) || (gc_zwol != null && gc_harm.after(gc_zwol)))  //jesli przed zatrudnieniem lub po zwolnieniu
                        {   //wpisz dzien wolny = niekasowalne godziny 'xx - xx' o id = 0
                            listaZapytan[x++] = "insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                    + "values (" + id + ", " + dzien + ", " + prac_id + ", " + 0 + ");";
                            System.out.println(listaZapytan[x-1]);
    
                        }else{
                            //wpisz zmianę
                            listaZapytan[x++] = "insert into tblZmiany (Harmonogram_id, dzien, pracownik_id, godziny_id) "
                                    + "values (" + id + ", " + dzien + ", " + prac_id + ", " + cykl.godziny[offset] + ");";
                            System.out.println("cykl.godziny[" + offset + "] = " + cykl.godziny[offset]);
                            System.out.println(listaZapytan[x-1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with Razor syntax and jQuery, I'm trying to append some items
I have problem witch change style border-left-color in next button, if main button is
I have problem in my PHP code. I'm trying to make internet shop and
I have problem with my own Subversion repository. It worked yesterday. But I received
I have problem with passing variables through views. But, first some code // i
I have problem with configuring NODE.JS. I was trying to install node.js with this
I have problem with loading my jqGrid. It just loads two parallel lines, and
I have problem with casting custom event currentTarget to component. When I'm trying to
I have problem in some JavaScript that I am writing where the Switch statement

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.