ResultSet videoFilenames should have 4162 lines (I tested the query in the database), but while while while (videoFilenames.next ()) only executes once - after the first file name in the ResultSet, the while loop ends! Can someone help me understand 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(); } }
source share