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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:18:12+00:00 2026-06-10T19:18:12+00:00

The ResultSet videoFilenames should have 4162 rows (I tested the query in the database)

  • 0

The ResultSet videoFilenames should have 4162 rows (I tested the query in the database) but the while loop ‘while (videoFilenames.next())’ only iterates once – after the first filename in the ResultSet, the while loop just ends! Can anyone help me figure out why?

/*
 * Run: java -cp .:ojdbc6.jar FindVideosWithoutTranscodes
 */

import java.io.*;
import java.sql.*;

public class FindVideosWithoutTranscodes {

    public static void main(String[] args) throws Exception {
        //connect to database
        Class.forName("oracle.jdbc.OracleDriver");
        String serverName = "***.***.***.***";
        String portNumber = "****";
        String sid = "*****";
        String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
        String username = "*****";
        String password = "*****";
        Connection conn = DriverManager.getConnection(url, username, password);
        Statement stmt = conn.createStatement();

        //create output file
        BufferedWriter out = new BufferedWriter(new FileWriter("mp2_files_without_transcodes.txt"));

        //get ResultSet of mp2 filenames
        ResultSet videoFilenames = stmt.executeQuery("select filename from archivefile where filename like '%.mp2'");

        System.out.println("Making list of mp2 files without transcodes...");

        //for each mp2 file
        String filename;
        ResultSet smallTranscode;
        ResultSet largeTranscode;
        while (videoFilenames.next()) {
            filename = videoFilenames.getString(1);

            //check for -700.mov file
            System.out.println(filename.substring(0, filename.length() - 4) + "-700.mov"); //test
            smallTranscode = stmt.executeQuery("select * from archivefile where filename='" + filename.substring(0, filename.length() - 4) + "-700.mov'");
            if (!smallTranscode.next())
                out.write(filename + "\n");
            else {
                //check for -6500.mov file
                System.out.println(filename.substring(0, filename.length() - 4) + "-6500.mov"); //test
                largeTranscode = stmt.executeQuery("select * from archivefile where filename='" + filename.substring(0, filename.length() - 4) + "-6500.mov'");
                if (!largeTranscode.next())
                    out.write(filename + "\n");
                largeTranscode.close();
            }
            smallTranscode.close();
        }

        System.out.println("Done.");

        out.close();
        videoFilenames.close();

    }

}
  • 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-10T19:18:14+00:00Added an answer on June 10, 2026 at 7:18 pm

    only one ResultSet object per Statement object can be open at the same
    time

    http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html

    So once you execute your second query inside your while loop using the same Statement instance you are closing your videoFilenames ResultSet.

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

Sidebar

Related Questions

I have a ResultSet object containing all the rows returned from an sql query.
I have a query that returns a resultset. And I want to apply filter
I have to use a Variable(Query Resultset) in ColdFusion , which will get the
I have a resultSet that I am pulling from my database: String selStmt =
I have got a ResultSet after firing a query. Kindly let me know how
I need a ResultSet for quick database export with openCSV. What I have is
I have a Sql ResultSet from a query. It has following fields: username, department,
I'm using resultSet.next() to check whether a unique row exist in the database or
How can I fetch large resultset in java? I have about 140,000 rows with
I have used a ResultSet that returns certain number of rows. My code is

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.