ResultSet videoFilenames には 4162 行が必要です (データベースでクエリをテストしました) が、while ループ 'while (videoFilenames.next())' は 1 回だけ繰り返されます - ResultSet の最初のファイル名の後、while ループはちょうど終了します! 誰でも理由を理解するのを手伝ってもらえますか?
/*
* 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();
}
}