This commit is contained in:
Ammar Askar
2012-11-07 18:28:03 +05:00
parent 6fb7077826
commit cf0688050f
5 changed files with 17 additions and 19 deletions

View File

@@ -38,7 +38,7 @@ public class DumpedLogImporter implements Runnable
for (final File sqlFile : imports) { for (final File sqlFile : imports) {
getLogger().info("Trying to import " + sqlFile.getName() + " ..."); getLogger().info("Trying to import " + sqlFile.getName() + " ...");
final BufferedReader reader = new BufferedReader(new FileReader(sqlFile)); final BufferedReader reader = new BufferedReader(new FileReader(sqlFile));
String line = null; String line;
while ((line = reader.readLine()) != null) while ((line = reader.readLine()) != null)
try { try {
st.execute(line); st.execute(line);

View File

@@ -544,7 +544,6 @@ public final class QueryParams implements Cloneable
value += args.get(j) + " "; value += args.get(j) + " ";
} }
continue;
} else { } else {
// The value ends with a double quote // The value ends with a double quote

View File

@@ -141,7 +141,7 @@ public class WorldEditor implements Runnable
if (!block.setTypeId(0)) if (!block.setTypeId(0))
throw new WorldEditorException(block.getTypeId(), 0, block.getLocation()); throw new WorldEditorException(block.getTypeId(), 0, block.getLocation());
} else if (ca != null && (type == 23 || type == 54 || type == 61 || type == 62)) { } else if (ca != null && (type == 23 || type == 54 || type == 61 || type == 62)) {
int leftover = 0; int leftover;
try { try {
leftover = modifyContainer(state, new ItemStack(ca.itemType, -ca.itemAmount, (short)0, ca.itemData)); leftover = modifyContainer(state, new ItemStack(ca.itemType, -ca.itemAmount, (short)0, ca.itemData));
if (leftover > 0) if (leftover > 0)

View File

@@ -28,10 +28,9 @@ import java.util.concurrent.locks.ReentrantLock;
public class MySQLConnectionPool implements Closeable public class MySQLConnectionPool implements Closeable
{ {
private final static int poolsize = 10; private final static int poolSize = 10;
private final static long timeToLive = 300000; private final static long timeToLive = 300000;
private final Vector<JDCConnection> connections; private final Vector<JDCConnection> connections;
private final ConnectionReaper reaper;
private final String url, user, password; private final String url, user, password;
private final Lock lock = new ReentrantLock(); private final Lock lock = new ReentrantLock();
@@ -40,9 +39,9 @@ public class MySQLConnectionPool implements Closeable
this.url = url; this.url = url;
this.user = user; this.user = user;
this.password = password; this.password = password;
connections = new Vector<JDCConnection>(poolsize); connections = new Vector<JDCConnection>(poolSize);
reaper = new ConnectionReaper(); ConnectionReaper reaper = new ConnectionReaper();
reaper.start(); new Thread(reaper, "MySQL Connection Reaper Thread - LogBlock").start();
} }
@Override @Override
@@ -95,7 +94,7 @@ public class MySQLConnectionPool implements Closeable
lock.unlock(); lock.unlock();
} }
private class ConnectionReaper extends Thread private class ConnectionReaper implements Runnable
{ {
@Override @Override
public void run() { public void run() {
@@ -112,14 +111,14 @@ public class MySQLConnectionPool implements Closeable
private class JDCConnection implements Connection private class JDCConnection implements Connection
{ {
private final Connection conn; private final Connection conn;
private boolean inuse; private boolean inUse;
private long timestamp; private long timestamp;
private int networkTimeout; private int networkTimeout;
private String schema; private String schema;
JDCConnection(Connection conn) { JDCConnection(Connection conn) {
this.conn = conn; this.conn = conn;
inuse = false; inUse = false;
timestamp = 0; timestamp = 0;
networkTimeout = 30; networkTimeout = 30;
schema = "default"; schema = "default";
@@ -132,12 +131,12 @@ public class MySQLConnectionPool implements Closeable
@Override @Override
public void close() { public void close() {
inuse = false; inUse = false;
try { try {
if (!conn.getAutoCommit()) if (!conn.getAutoCommit())
conn.setAutoCommit(true); conn.setAutoCommit(true);
} catch (final SQLException ex) { } catch (final SQLException ex) {
connections.remove(conn); connections.remove(this);
terminate(); terminate();
} }
} }
@@ -407,7 +406,7 @@ public class MySQLConnectionPool implements Closeable
} }
boolean inUse() { boolean inUse() {
return inuse; return inUse;
} }
boolean isValid() { boolean isValid() {
@@ -419,9 +418,9 @@ public class MySQLConnectionPool implements Closeable
} }
synchronized boolean lease() { synchronized boolean lease() {
if (inuse) if (inUse)
return false; return false;
inuse = true; inUse = true;
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
return true; return true;
} }

View File

@@ -118,10 +118,10 @@ public class Utils
if (s == null || s.length == 0) if (s == null || s.length == 0)
return ""; return "";
final int len = s.length; final int len = s.length;
final StringBuffer buffer = new StringBuffer(s[0]); final StringBuilder builder = new StringBuilder(s[0]);
for (int i = 1; i < len; i++) for (int i = 1; i < len; i++)
buffer.append(delimiter).append(s[i]); builder.append(delimiter).append(s[i]);
return buffer.toString(); return builder.toString();
} }
public static class ExtensionFilenameFilter implements FilenameFilter public static class ExtensionFilenameFilter implements FilenameFilter