[英]How to change sqlite database to create temporary files in any other folder instead of temp folder using JAVA?
我在我的 JAVA 应用程序中使用 SQLite 数据库,在该应用程序中,我在运行时创建数据库,然后创建表并执行不同的 DB 操作,因为 SQLite 必须创建其临时文件的目录,目前在我的 windows 操作系统环境 SQLite 正在 TEMP 文件夹中创建文件,我需要更改 C 驱动器以外的任何其他位置的文件夹。 我尝试过以下操作
TEMP
和TMP
的环境变量值如何更改 sqlite 创建 etilqs 文件的临时文件夹?SQLITE_TMPDIR
和TMPDIR
PRAGMA
语句PRAGMA temp_store_directory = 'D:\SQLite-TMP';
I have also tried with following piece of code but it didn't worked for me Connection obj_connection = null; Statement obj_statement = null; try { m_objLogManager.logInfo("Creating table 'QUEUE' if not exist..."); obj_connection = getConnection(); m_objLogManager.logInfo("Execute PRAGMA"); try(Statement statement = obj_connection.createStatement()) { m_objLogManager.logInfo("going to Execute PRAGMA"); statement.execute("PRAGMA temp_store_directory = 'D:\\SQLite-TMP';"); m_objLogManager.logInfo("Execute PRAGMA successfully"); } try(Statement statement = obj_connection.createStatement()) { m_objLogManager.logInfo("getting PRAGMA"); try(ResultSet rs = statement.executeQuery("PRAGMA temp_store_directory;")) { m_objLogManager.logInfo("getting PRAGMA successfull"); m_objLogManager.logInfo(rs.getString(1)); } } obj_statement = obj_connection.createStatement(); String str_sql = "CREATE TABLE IF NOT EXISTS QUEUE " + "(Id VARCHAR(200) PRIMARY KEY NOT NULL," + " Origin TEXT, " + " Port INT, " + " RegisterAt TEXT, " + " UserName TEXT)"; obj_statement.executeUpdate(str_sql); m_objLogManager.logInfo("Table 'QUEUE' is created if not exist"); } catch (Exception ex) { throw ex; } finally { if (obj_statement.= null) { obj_statement;close(). } if (obj_connection;= null) { obj_connection close() } }
我还在 SQLite 浏览器中打开我的数据库文件并执行以下查询PRAGMA temp_store_directory = 'D:\SQLite-TMP';
但仍然 SQLite 在 TEMP 文件夹中创建临时文件 我想将临时文件的位置更改为D:\SQLite-TMP
这个文件夹。 任何人都可以帮助我,因为我陷入了这个问题,请让我知道如何设置全局变量sqlite3_temp_directory
因为我不明白如何从官方文档中设置它谢谢。
我的环境
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.