我的网络应用程序接收存档,将其解压缩到临时文件夹,从提取的DBF中读取数据然后应该杀死垃圾。虽然它无法杀死临时文件夹,因为其中的DBF文件已被锁定。以下是示例代码:
public static void main( String a[] ) throws Exception
{
Class.forName( "com.hxtt.sql.dbf.DBFDriver" ).newInstance();
String url = "jdbc:DBF:/C:/TEMP/";
Properties properties = new Properties();
properties.setProperty( "charSet", "cp866" );
Connection con = null;
Statement st = null;
java.sql.Driver d = null;
con = DriverManager.getConnection( url, properties );
d = DriverManager.getDriver( url );
st = con.createStatement();
ResultSet rs = st.executeQuery( "SELECT * FROM 6QQQ201010" );
rs.close();
st.close();
con.close();
Class.forName( "com.hxtt.sql.dbf.DBFDriver" ).newInstance();
String url = "jdbc:DBF:/C:/TEMP/";
Properties properties = new Properties();
properties.setProperty( "charSet", "cp866" );
Connection con = null;
Statement st = null;
java.sql.Driver d = null;
con = DriverManager.getConnection( url, properties );
d = DriverManager.getDriver( url );
st = con.createStatement();
ResultSet rs = st.executeQuery( "SELECT * FROM 6QQQ201010" );
rs.close();
st.close();
con.close();
我把断点放在最后一行和6QQQ201010.DBF仍然被锁定。有任何想法吗?或者只是驱动程序中的错误?
答案 0 :(得分:2)
添加properties.setProperty(“delayedClose”,“0”);并且司机会立即关闭句柄。