db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Skiles" <dski...@docfinity.com>
Subject RE: Error 38000 with a stack overflow on recordset.next()?
Date Tue, 18 Oct 2005 14:32:39 GMT
Daniel, any chance of posting a complete repro, so I can recreate the
problem to debug? I am also baffled by the stack trace and your
description of your program. Though your stack trace is useful, it would
be lot more useful to generate it with actual line numbers of the code.
I can do this and also investigate the problem if I can get a complete
reproduction posted.




I can't post the exact code, but I can post most of it.  I had to rip
some bits out here and there because of company policy.  If anything
looks out of whack, please let me know.  Thanks for the help.
 
package com.docfinity.orphantracker;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
 
public class CommandLineLocal {
               public static void main(String[] args) throws
IOException{
                               String[] searchDrives = null;
                               String input = null;
                               String fileSystemSearchPath = null;
                               String missingFilePath = null;
                               Map missingFiles = new HashMap();
                               List filesThatAreMissingRows = new
ArrayList();
                               
                               boolean successful = false;
                               
                               Connection localConn = null;
                               PreparedStatement localStmnt = null;
                               
                               
                               try {
 
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
                                              localConn =
DriverManager.getConnection("jdbc:derby:local;create=true","sa","");
                               } catch (ClassNotFoundException cnfe) {
 
System.err.println(cnfe.getMessage());
                                              System.exit(2);
                               } catch (SQLException sqle) {
 
System.err.println(sqle.getMessage());
                                              System.exit(3);
                               }
                               
                               try {
                                              File testFile = null;
                                              String normalizedPath =
null;
                                              
                                              localStmnt =
localConn.prepareStatement("DROP table existingfiles");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                                              localStmnt =
localConn.prepareStatement("CREATE table existingfiles (path
varchar(100), pg_id int)");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                                              localStmnt =
localConn.prepareStatement("INSERT into existingfiles (path, pg_id)
VALUES (?, ?)");
                                              
                                              //MISSING CODE ALERT
                                              //dbFileInfo is the
resultset from a query that I had to rip out of this code.  It returns
an integer, a string, and a string.                  
                                              //END MISSING CODE ALERT
                                              while(dbFileInfo.next()) {
                                                             successful
= false;
 
                                                             //MISSING
CODE ALERT
                                                             //I had to
rip more code out of here, but I build a path based on the values that
got back from dbFileInfo.
                                                             //I store
the result in in the String normalizedPath.
                                                             //The
integer value gets stored in the column pg_id
                                                             //END
MISSING CODE ALERT                                               
 
                                                             testFile =
new File(normalizedPath);
 
if(testFile.exists()) {
 
successful = true;
 
localStmnt.setString(1, normalizedPath);
 
localStmnt.setInt(2, $INTEGER_VALUE_THAT_I_GOT_FROM_dbFileInfo);
 
localStmnt.executeUpdate();
 
localStmnt.clearParameters();
                                                             }
 
if(!successful) {
 
missingFiles.put(normalizedPath, Integer.toString(pg_id));
                                                             }
                                              }
                                              
                                              dbFileInfo.close();
                                              dbFileInfo = null;
                                              localStmnt.close();
                                              localStmnt = null;
 
System.out.println("Finished inserting into existingfiles.");
                                              
                               } catch (SQLException sqle) {
 
System.err.println(sqle.getMessage());
                                              System.exit(4);
                               }
                               
                               dumpMap(missingFilePath, missingFiles);
                               missingFiles = null;
                               System.gc();
                               System.out.println("Finished inserting
into dumping and gc'ing missingFiles.");
                               
                               try {                         
                                              localStmnt =
localConn.prepareStatement("DROP TABLE filesystemfiles");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                                              localStmnt =
localConn.prepareStatement("CREATE TABLE filesystemfiles (path
varchar(100))");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                                              localStmnt =
localConn.prepareStatement("INSERT INTO filesystemfiles (path) VALUES
(?)");
 
setFileSystemFiles(fileSystemSearchPath, localStmnt);
                                              localStmnt.close();
                                              localStmnt = null;
 
System.out.println("Finished inserting into filesystemfiles.");
                                              localStmnt =
localConn.prepareStatement("SELECT path from filesystemfiles where path
not in (select path from existingfiles)");
                                              dbFileInfo =
localStmnt.executeQuery();
 
System.out.println("Finished big select.");
                                              
                                              while(dbFileInfo.next()) {
 
filesThatAreMissingRows.add(dbFileInfo.getString("path"));
                                              }
                                              localStmnt.close();
                                              
                                              localStmnt =
localConn.prepareStatement("DROP table existingfiles");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                                              
                                              localStmnt =
localConn.prepareStatement("DROP TABLE filesystemfiles");
 
localStmnt.executeUpdate();
                                              localStmnt.close();
                                              localStmnt = null;
                               } catch (SQLException sqle) {
                                              do {
 
System.out.println(sqle.getSQLState() + "-" + sqle.getMessage());
 
sqle.printStackTrace(System.out);
                                                             sqle =
sqle.getNextException();
                                              } while (sqle != null);
                               }
                               System.out.println("Finished adding items
to filesThatAreMissingRows.");
                               dumpCollection(missingOptimg01Path,
filesThatAreMissingRows);
               }
               
               
               /////////////////////////////////
               
               public static void dumpMap(final String path, final Map
map) throws IOException {
                               FileWriter outStream = new
FileWriter(path);
                               Map.Entry item = null;
                               Set entrySet = map.entrySet();
                               Iterator it = entrySet.iterator();
                               
                               while(it.hasNext()) {
                                              item =
(Map.Entry)it.next();
 
outStream.write(item.getKey()+"\t"+item.getValue()+"\r\n");
                               }
                               outStream.close();
               }
               
               public static void dumpCollection(final String path,
final Collection coll) throws IOException {
                               Iterator it = coll.iterator();
                               FileWriter outStream = new
FileWriter(path);
                               String line = null;
                               
                               while(it.hasNext()) {
                                              line = (String)it.next();
 
outStream.write(line+"\r\n");
                               }
                               outStream.close();
               }
               
               public static String getInput(String message) {
                               BufferedReader stdIn = new
BufferedReader(new InputStreamReader(System.in));
                               String input = null;
                               
                               System.out.print(message);
                               try {
                                              input = stdIn.readLine();
                               } catch (IOException ioe) {
                                              //This should never, ever
happen.
 
System.out.println(ioe.getMessage());
                                              System.exit(5);
                               }
                               input = input.trim();
                               
                               return input;
               }
               
               public static Connection createConnectionFromInput()
throws IOException, ClassNotFoundException, SQLException {
                               String className = null;
                               String url = null;
                               String user = null;
                               String password = null;
                               String propsLoc = null;
                               
                               Properties props = new Properties();
                               
                               propsLoc = getInput("Where is your
connection properties file?  ");
                               props.load(new
FileInputStream(propsLoc));
                               
                               className = props.getProperty("class");
                               url = props.getProperty("url");
                               user = props.getProperty("username");
                               password = props.getProperty("password");
                               
                               Class.forName(className);
                               
                               return DriverManager.getConnection(url,
user, password);
                               
               }
               
               public static void setFileSystemFiles(final String
rootPath, PreparedStatement stmnt) throws SQLException {
                               File rootDir = new File(rootPath);
                               String[] subPaths = rootDir.list();
                               File subFile = null;
                               
                               if(!rootDir.exists()) {
                                              System.err.println("Root
path does not exist");
                                              System.exit(101);
                               }
                               
                               for(int i=0; i<subPaths.length; i++) {
                                              subFile = new
File(rootDir, subPaths[i]);
                                              if (subFile.isDirectory())
{
 
setFileSystemFiles(subFile.getAbsolutePath(), stmnt);
                                              }
                                              else {
 
stmnt.setString(1, subFile.getAbsolutePath().toLowerCase());
 
stmnt.executeUpdate();
 
stmnt.clearParameters();
                                              }
                               }
               }
}
 

Mime
View raw message