From 2012454b75c6bab75f8b29f8a6cecf537be6e40e Mon Sep 17 00:00:00 2001 From: Robin Kupper Date: Fri, 6 May 2011 00:10:06 +0200 Subject: [PATCH] Fixed writelock issue. --- src/de/diddiz/LogBlock/LBPlayerListener.java | 2 ++ src/de/diddiz/util/ConnectionPool.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/de/diddiz/LogBlock/LBPlayerListener.java b/src/de/diddiz/LogBlock/LBPlayerListener.java index 5eaa99d..70d9a93 100644 --- a/src/de/diddiz/LogBlock/LBPlayerListener.java +++ b/src/de/diddiz/LogBlock/LBPlayerListener.java @@ -53,8 +53,10 @@ public class LBPlayerListener extends PlayerListener return; Statement state = null; try { + conn.setAutoCommit(false); state = conn.createStatement(); state.execute("INSERT IGNORE INTO `lb-players` (playername) VALUES ('" + event.getPlayer().getName() + "');"); + conn.commit(); } catch (final SQLException ex) { log.log(Level.SEVERE, "[LogBlock] SQL exception", ex); } finally { diff --git a/src/de/diddiz/util/ConnectionPool.java b/src/de/diddiz/util/ConnectionPool.java index d576d10..e0e2ed4 100644 --- a/src/de/diddiz/util/ConnectionPool.java +++ b/src/de/diddiz/util/ConnectionPool.java @@ -136,6 +136,13 @@ public class ConnectionPool { @Override public void close() { inuse = false; + try { + if (!conn.getAutoCommit()) + conn.setAutoCommit(true); + } catch (SQLException ex) { + removeConnection(this); + terminate(); + } } @Override