使用JDBC将SQLite db加载到Java中的内存中?

时间:2019-05-17 10:43:26

标签: java scala sqlite jdbc

通常从文件中读取SQLite数据库。如果数据库足够大,则每个操作都可能需要文件I / O操作,这可能会很慢。

但是SQLite提供了一种将数据库加载到内存的方法-可以使用看起来像jdbc:memory...的JDBC URL来访问它。

例如,此问题描述了如何使用python实现这一目标:How to load existing db file to memory in Python sqlite3?

但是我不知道如何使用JDBC在Java或Scala中实现相同的功能。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

我刚刚尝试使用Xerial的sqlite-jdbc-3.27.2.1.jar,看来它们让我们 override fun onMapReady(gMap: GoogleMap?) { gMap?.let { it.setOnMarkerClickListener { var clickCount = it.tag as Int? // Check if a click count was set, then display the click count. if (clickCount != null) { clickCount = clickCount!! + 1 it.tag = clickCount Toast.makeText( this@MapFragment.context, it.title + " has been clicked " + clickCount + " times.", Toast.LENGTH_SHORT ).show() } // Return false to indicate that we have not consumed the event and that we wish // for the default behavior to occur (which is for the camera to move such that the // marker is centered and for the marker's info window to open, if it has one). false } } } 原生(二进制)SQLite数据库文件进入restore from数据库,如下所示:

:memory: