fixed memleak in ge sqlite connection
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package rs09.game.ge
|
package rs09.game.ge
|
||||||
|
|
||||||
import core.cache.def.impl.ItemDefinition
|
import core.cache.def.impl.ItemDefinition
|
||||||
import core.game.ge.OfferState
|
|
||||||
import core.game.node.entity.player.link.audio.Audio
|
|
||||||
import org.json.simple.JSONArray
|
import org.json.simple.JSONArray
|
||||||
import org.json.simple.JSONObject
|
import org.json.simple.JSONObject
|
||||||
import org.json.simple.parser.JSONParser
|
import org.json.simple.parser.JSONParser
|
||||||
@@ -10,17 +8,15 @@ import org.sqlite.SQLiteDataSource
|
|||||||
import rs09.ServerConstants
|
import rs09.ServerConstants
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
import java.lang.Integer.min
|
|
||||||
import java.sql.Connection
|
import java.sql.Connection
|
||||||
import java.sql.DriverManager
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of methods for interacting with the grand exchange databases
|
* Collection of methods for interacting with the grand exchange databases
|
||||||
* @author Ceikry
|
* @author Ceikry
|
||||||
*/
|
*/
|
||||||
object GEDB {
|
object GEDB {
|
||||||
var pathString = ""
|
private var pathString = ""
|
||||||
var connection: Connection? = null
|
private var connection: Connection? = null
|
||||||
|
|
||||||
//This needs to be a separate method, so we can call it after the server config has been parsed
|
//This needs to be a separate method, so we can call it after the server config has been parsed
|
||||||
fun init()
|
fun init()
|
||||||
@@ -34,7 +30,7 @@ object GEDB {
|
|||||||
|
|
||||||
fun connect(): Connection
|
fun connect(): Connection
|
||||||
{
|
{
|
||||||
if(connection == null || connection?.isClosed == true)
|
if (connection == null || connection!!.isClosed)
|
||||||
{
|
{
|
||||||
val ds = SQLiteDataSource()
|
val ds = SQLiteDataSource()
|
||||||
ds.url = "jdbc:sqlite:$pathString"
|
ds.url = "jdbc:sqlite:$pathString"
|
||||||
@@ -161,5 +157,6 @@ object GEDB {
|
|||||||
statement.execute("insert into price_index(item_id, value) values(${def.id},${def.value})")
|
statement.execute("insert into price_index(item_id, value) values(${def.id},${def.value})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
statement.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +104,7 @@ class GrandExchange : StartupListener {
|
|||||||
if(offer.amountLeft != before)
|
if(offer.amountLeft != before)
|
||||||
SystemLogger.logGE("Purchased FROM BOT ${offer.amountLeft - before}x ${getItemName(offer.itemID)}")
|
SystemLogger.logGE("Purchased FROM BOT ${offer.amountLeft - before}x ${getItemName(offer.itemID)}")
|
||||||
}
|
}
|
||||||
|
botStmt.close()
|
||||||
}
|
}
|
||||||
sellStmt.close()
|
sellStmt.close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user