package org.poopki.duckdns.user_db.DB; import org.poopki.duckdns.user_db.UserInfoArray; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; public class DBUpdate { private static final String DB_DRIVER_CLASS = "org.mariadb.jdbc.Driver"; private static final String DB_URL = "jdbc:mariadb://poopki.duckdns.org:3307/mc_dev"; private static final String DB_USERNAME = "mc_dev"; private static final String DB_PASSWORD = "!Rkdalsrn1027"; private static UserInfoArray m_InfoArrayInstance; public DBUpdate(UserInfoArray m_UIA){ m_InfoArrayInstance = m_UIA; } public static void UpdateDB(){ Connection conn = null; Statement stmt = null; try { Class.forName("org.mariadb.jdbc.Driver"); conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD); System.out.println("Connection success"); stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); /* String sql = sb.append("create table if not exists UserInfo(") .append("UUID varchar(36),") .append("Nation int(8)") .append("Occupation TINYINT,") .append("Squad int,") .append("Farm int,") .append("Account int,") .append(")").toString(); stmt.execute(sql); */ for (UUID key : m_InfoArrayInstance.m_UserInfoArray.keySet()) { //sql = sb.append("insert into UserInfo values('"+key+"',"+0+","+0+","+0+","+0+","+0+")").toString(); String sql = sb.append("insert into UserInfo values ('test', 0)").toString(); stmt.execute(sql); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block System.err.println("에러 내용 :" + e.getMessage()); System.out.println("DB Connection fail"); } } }