I'm getting a Result Set closed exception every time I hit a file which isn't in the database.
Here's the java code: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package testsqlite; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.sql.*; import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author chris */ public class Main { /** * @param args the command line arguments */ private static Connection conn; private static String sql="INSERT INTO part(name,md5sum,size,pfad) VALUES (?,?,?,?)"; private static PreparedStatement pstmnt,pstmnt_ifexists ; // private static String sql_ifexists="SELECT COUNT(*) FROM part WHERE md5sum=?"; public static void main(String[] args) throws Exception{ // TODO code application logic here System.out.println("Testsuite-Collector\n"); String path="c:/usr/local/www/data/test/mandanten/chris/probanden"; File f = new File(path); Class.forName ("org.sqlite.JDBC"); conn = DriverManager.getConnection("jdbc:sqlite:c:/users/chris/testsuite/versionen.sqlite"); Statement stat = conn.createStatement(); pstmnt = conn.prepareStatement(sql); //pstmnt_ifexists = conn.prepareStatement(sql_ifexists); Traverse(f); ResultSet rs = stat.executeQuery("select md5sum, pfad from part where md5sum in (select md5sum from part group by md5sum having count(*) > 1);"); while (rs.next()) { System.out.print("pfad=" + rs.getString("pfad") + " "); System.out.println("md5sum= " + rs.getString("md5sum")); } rs.close(); conn.close(); } private static void Traverse(File f) throws IOException { File[] files = f.listFiles(); for( File file : files) { if(file.isDirectory()){ Traverse(file); } else { try { FileInputStream fis = new FileInputStream( file ); String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex( fis ); System.out.println(file.length() +" " +md5+"->"+file.getPath()); Statement ifexist = conn.createStatement(); ResultSet rs =ifexist.executeQuery("select pfad from part where pfad='"+file.getPath()+"';"); if(rs.getString(1).isEmpty()) { rs.close(); pstmnt.setString(1, file.getName()); pstmnt.setString(2, md5); pstmnt.setLong(3, file.length()); pstmnt.setString(4, file.getPath()); pstmnt.executeUpdate(); } else { rs.close(); System.out.println(file.getName()+" exists."); } } catch (SQLException e) { System.out.println("SQL error:" +e.getMessage()+"\n"); } } } } } Any clues? -- Christoph _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users