Jak powinienem zmodyfikować swoja metode, zeby wyglądało i działała poprawnie?
public void run() {
Connection con = getConnection();
while (true) {
QueueNotify actionFileContent = null;
try {
actionFileContent = sharedQueue.take();
} catch (InterruptedException e) {
e.printStackTrace();
}
PreparedStatement ps = null;
try {
ps = db.writeData(con, actionFileContent);
} catch (Exception e) {
e.printStackTrace();
} finally {
db.close(con, ps);
}
}
}
private Connection getConnection() {
Connection con = null;
try {
con = db.connect();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return con;
}