Refactored DatabaseFactory.
This commit is contained in:
@@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.communitybbs.Manager.ForumsBBSManager;
|
||||
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class Forum
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@@ -112,7 +112,7 @@ public final class Forum
|
||||
_log.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@@ -137,7 +137,7 @@ public final class Forum
|
||||
|
||||
private void getChildren()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@@ -215,7 +215,7 @@ public final class Forum
|
||||
|
||||
public void insertIntoDb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) VALUES (?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
|
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.communitybbs.Manager.PostBBSManager;
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public class Post
|
||||
|
||||
public void insertindb(CPost cp)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, cp.postId);
|
||||
@@ -102,7 +102,7 @@ public class Post
|
||||
public void deleteme(Topic t)
|
||||
{
|
||||
PostBBSManager.getInstance().delPostByTopic(t);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?"))
|
||||
{
|
||||
ps.setInt(1, t.getForumID());
|
||||
@@ -120,7 +120,7 @@ public class Post
|
||||
*/
|
||||
private void load(Topic t)
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC"))
|
||||
{
|
||||
ps.setInt(1, t.getForumID());
|
||||
@@ -153,7 +153,7 @@ public class Post
|
||||
public void updatetxt(int i)
|
||||
{
|
||||
final CPost cp = getCPost(i);
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?"))
|
||||
{
|
||||
ps.setString(1, cp.postTxt);
|
||||
|
@@ -21,7 +21,7 @@ import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.communitybbs.Manager.TopicBBSManager;
|
||||
|
||||
public class Topic
|
||||
@@ -71,7 +71,7 @@ public class Topic
|
||||
|
||||
public void insertindb()
|
||||
{
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _id);
|
||||
@@ -129,7 +129,7 @@ public class Topic
|
||||
{
|
||||
TopicBBSManager.getInstance().delTopic(this);
|
||||
f.rmTopicByID(getID());
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?"))
|
||||
{
|
||||
ps.setInt(1, getID());
|
||||
|
Reference in New Issue
Block a user