- Joined
- May 17, 2007
- Messages
- 2,468
- Reaction score
- 681
Hello
today i looked into MySQL database pooling and thought i'd start pooling my database, instead of it having to go though 200-300 queries a second.
Here is class:
The problem, is that is gives me an error:
Apparently, the mysql exception catched, using printed / used. But i'm printing out the stacktrace of the error
Any ideas?
the stmt is inside the try statement, but can't think of an alt
Thank you
today i looked into MySQL database pooling and thought i'd start pooling my database, instead of it having to go though 200-300 queries a second.
Here is class:
PHP:
/************************************************\
* ############################################ *
* ## RageScape 508 Server ## *
* ############################################ *
\************************************************/
package com.aj.ragescape.io;
import java.sql.*;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import com.aj.ragescape.Server;
import com.aj.ragescape.Engine;
import com.aj.ragescape.util.Misc;
import com.aj.ragescape.threads.databaseWorker;
import com.aj.ragescape.threads.socketWorker;
import com.aj.ragescape.threads.musWorker;
public class MySQL {
public static int executeUpdate(String query) {
int recordsUpdated = 0;
Statement stmt = null;
try {
stmt = Server.DBConnection.createStatement();
recordsUpdated = stmt.executeUpdate(query);
stmt.close();
stmt = null;
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
stmt = null;
}
}
return recordsUpdated;
}
public static ResultSet executeQuery(String query) {
ResultSet RS = null;
try {
Statement stmt = Server.DBConnection.createStatement();
RS = stmt.executeQuery(query);
stmt.close();
stmt = null;
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
stmt = null;
}
}
return RS;
}
}
The problem, is that is gives me an error:
![TheAJ - [Java] pooling - RaGEZONE Forums TheAJ - [Java] pooling - RaGEZONE Forums](https://forum.ragezone.com/images/404_image.png)
Apparently, the mysql exception catched, using printed / used. But i'm printing out the stacktrace of the error
Any ideas?
the stmt is inside the try statement, but can't think of an alt
Thank you
Last edited: