Ver código fonte

BETA: Adding useful method in L2DatabaseFactory it's designed for simple db operations like INSERT, UPDATE, DELETE.

Rumen Nikiforov 12 anos atrás
pai
commit
be3b2b331a

+ 20 - 0
L2J_Server_BETA/java/com/l2jserver/L2DatabaseFactory.java

@@ -15,6 +15,7 @@
 package com.l2jserver;
 
 import java.sql.Connection;
+import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.Map;
 import java.util.concurrent.Executors;
@@ -402,4 +403,23 @@ public class L2DatabaseFactory
 	{
 		return _providerType;
 	}
+	
+	/**
+	 * Designed to execute simple db operations like INSERT, UPDATE, DELETE.
+	 * @param query
+	 * @param params
+	 * @throws SQLException
+	 */
+	public void executeQuery(String query, Object... params) throws SQLException
+	{
+		try (Connection con = getConnection();
+			PreparedStatement st = con.prepareStatement(query))
+		{
+			for (int i = 0; i < params.length; i++)
+			{
+				st.setObject(i + 1, params[i]);
+			}
+			st.execute();
+		}
+	}
 }