We are using (recently purchased) DBF_JDBC30.jar to read DBF files. This is what program does:
1. DBF files come in zip file. It unzips in a Dir and renames with .DBF extension.
2. Gets DBConn as
String dBUrl = URLPREFIX + workDir.getAbsolutePath(); //work dir
3. Execute select SQL on each file in the Dir:
String sql = "select * from " + finalFileName;
ResultSet rs = stmt.executeQuery(sql);
4. Read file and populate appropriate xml elements from the data read.
Above steps happen in non static method.
The test we did:
1. Created a test class that spawns mulitple thread and invokes above class. The input to all thread is single zip file. But the unzip for each thread happens in a new location. Hence the actual .DBF files reside in seperate dir for each thread. (also we change the .DBF file name so that they remain unique for each thread)
Almost in every test we get following exception:
"Failed to access table xxxx for it has been closed. //xxx is actually dbf file name."
When I ran 5 threads test, sometimes 2 thread failed sometimes 3. Its not consistenet.
Even though each thread gets new instace of above class and read a DBF file which has diff name than other thread (although data is same) we are wondering why its throwing above exception. It seems to me that its not thread safe.
P.S. If there is any contact number please email it to me,so that if further info is needed we can disciss this.
>"Failed to access table xxxx for it has been closed. //xxx is actually dbf
> file name."
It means that you're accesing a closed table. I guess that maybe your code is holding an opening resultSet, but it's closed by ResultSet.close, Statement.close, Statement.execute, or Connection.close, in other thread. You can email email@example.com your sample so that we can check it.
>1. DBF files come in zip file. It unzips in a Dir and renames with .DBF extension.
HXTT DBF support directly zip url, and support other table extension too.
I reinspected my code again. Since the method that reads the DBF file is non static, each thread gets (should get) its own instance of DbConnection and resultset object (since these are local object in non static method). Hence they should not be interfering with each other's operation. That's what I was thinking.
I have sent the code snippet to the above email id.
Well, I guess I found the reason for this.
Actually I am using
Once all the files in a given directory are read.
I commented out this and now its working.
But this creates another issue. (I added that code to resolve this issue)
I cant delete this temp unzipped files after read is complete. Seems like driver keeps hold on this file for quite some time.
Is there a way to just release perticuler set of files? (and not all?)
>Actually I am using
That's the key because it will release all holding tables.
>I cant delete this temp unzipped files after read is complete. Seems like driver
> keeps hold on this file for quite some time.
>Is there a way to just release perticuler set of files? (and not all?)
Set delayedClose=-1 connection property.
BTW, please read Compressed Database:(.ZIP, .JAR, .GZ, .TAR, .BZ2, .TGZ, .TAR.GZ, .TAR.BZ2). Maybe you needn't to do unzip/delete. You can try to use one thread to process one zip file.