HXTT ACCESS
temporary ms access file cannot be deleted
Mdurovic
2008-06-26 20:37:18.0
Hi,

I'm evaluating your HXTT Access package and I have a problem. The test I'm doing is the following:

1) I create, from within a Java program, a temporary database file, by copying from the original.

2) I load your driver and read a table from the database. This works, ie. your JDBC driver can read this database without problems.

3) then I try to delete the database file, AFTER closing the recordset and the connection. It fails.

If I comment out the code where I create the connection to the database via your driver (see below, between "Start using JDBC" and "end using JDBC") , deletion works fine. So, it's your driver that's locking it somehow.

The code goes like this:

File temp = File.createTempFile( "mytemp", ".mdb" );
... // copy from another location
// Start using JDBC
Class.forName( "com.hxtt.sql.access.AccessDriver" ).newInstance();
Connection conn = DriverManager.getConnection( "jdbc:access:///" +
temp.getAbsolutePath().replaceAll( "\\\\", "/" ) );
Statement command = conn.createStatement();
ResultSet rs = command.executeQuery( "select * FROM mytable" );
while (rs.next())
{
System.out.println(rs.getString(1));
}
rs.close();
conn.close();
// end using JDBC
if( !temp.delete() ) // don't need it any more
{
log.error( "Failed to delete: " + temp.getAbsolutePath() );
}

So, what can I do about it?

Cheers,
Mdurovic
Re:temporary ms access file cannot be deleted
HXTT Support
2008-06-26 21:13:04.0
You can use delayedClose=0 connection property.
delayedClose: Indicates the delayed seconds for close transaction. That option is used to avoid frequent close/open table operations for following sqls. You can use 0~120 seconds. Default: 3.
Re:Re:temporary ms access file cannot be deleted
aa
2008-06-26 21:23:08.0
yes, it fixed it. Thanks.


Google