diff --git a/src/main/java/com/exortions/pluginutils/database/MySQLResultSetUtils.java b/src/main/java/com/exortions/pluginutils/database/MySQLResultSetUtils.java new file mode 100644 index 0000000..1f3cf11 --- /dev/null +++ b/src/main/java/com/exortions/pluginutils/database/MySQLResultSetUtils.java @@ -0,0 +1,241 @@ +package com.exortions.pluginutils.database; + +import javax.annotation.Nullable; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +/** + * @since 0.4.24.23 + */ +@SuppressWarnings("unused") +public class MySQLResultSetUtils { + + public static HashMap getValuedMapFromSet(String asKey, String asValue, ResultSet set){ + HashMap map = new HashMap(); + try { + while(set.next()) { + map.put(set.getObject(asKey), set.getObject(asValue)); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return map; + } + + public static LinkedHashMap getValuedLinkedMapFromSet(String asKey, String asValue, ResultSet set){ + LinkedHashMap map = new LinkedHashMap(); + try { + while(set.next()) { + map.put(set.getObject(asKey), set.getObject(asValue)); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return map; + } + + + public static List getObjectsFromSet(String columnName, ResultSet set){ + List list = new ArrayList(); + try { + while(set.next()) { + Object value = set.getObject(columnName); + if (set.wasNull()){ + continue; + } + list.add(value); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + + public static Object getObjectFromSet(String columnName, ResultSet set){ + Object value = null; + try { + while(set.next()) { + value = set.getObject(columnName); + if (set.wasNull()){ + value = null; + } + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return value; + } + + public static Integer getIntegerFromSet(String columnName, ResultSet set){ + Integer value = null; + try { + while(set.next()) { + value = set.getInt(columnName); + if (set.wasNull()){ + value = null; + } + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return value; + } + + public static List getIntegersFromSet(String columnName, ResultSet set){ + List list = new ArrayList(); + try { + while(set.next()) { + Integer value = set.getInt(columnName); + if (set.wasNull()){ + continue; + } + list.add(value); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + public static Long getLongFromSet(String columnName, ResultSet set){ + Long value = null; + try { + while(set.next()) { + value = set.getLong(columnName); + if (set.wasNull()){ + value = null; + } + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return value; + } + + public static List getLongsFromSet(String columnName, ResultSet set){ + List list = new ArrayList(); + try { + while(set.next()) { + Long value = set.getLong(columnName); + if (set.wasNull()){ + continue; + } + list.add(value); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + + public static Double getDoubleFromSet(String columnName, ResultSet set){ + Double value = null; + try { + while(set.next()) { + value = set.getDouble(columnName); + if (set.wasNull()){ + value = null; + } + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return value; + } + + public static List getDoublesFromSet(String columnName, ResultSet set){ + List list = new ArrayList(); + try { + while(set.next()) { + Double value = set.getDouble(columnName); + if (set.wasNull()){ + continue; + } + list.add(value); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + + public static Short getShortFromSet(String columnName, ResultSet set){ + Short value = null; + try { + while(set.next()) { + value = set.getShort(columnName); + if (set.wasNull()){ + value = null; + } + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return value; + } + + public static List getShortsFromSet(String columnName, ResultSet set){ + List list = new ArrayList(); + try { + while(set.next()) { + Short value = set.getShort(columnName); + if (set.wasNull()){ + continue; + } + list.add(value); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return list; + } + + + @Nullable + public static String getStringFromSet(String columnName, ResultSet set){ + String name = null; + try { + while(set.next()) { + name = set.getString(columnName); + } + set.beforeFirst(); + } catch (SQLException e) { + e.printStackTrace(); + } + return name; + } + + + public static ArrayList getStringsFromSet(String columnName, ResultSet set){ + ArrayList list = new ArrayList(); + try { + while(set.next()) { + String name = set.getString(columnName); + list.add(name); + } + set.beforeFirst(); + } catch (SQLException e1) { + e1.printStackTrace(); + } + return list; + } +} \ No newline at end of file diff --git a/target/ExosPluginUtils-0.4.25.23.jar b/target/ExosPluginUtils-0.4.25.23.jar new file mode 100644 index 0000000..94c6be4 Binary files /dev/null and b/target/ExosPluginUtils-0.4.25.23.jar differ diff --git a/target/classes/com/exortions/pluginutils/database/MySQLResultSetUtils.class b/target/classes/com/exortions/pluginutils/database/MySQLResultSetUtils.class new file mode 100644 index 0000000..3d4f957 Binary files /dev/null and b/target/classes/com/exortions/pluginutils/database/MySQLResultSetUtils.class differ diff --git a/target/classes/com/exortions/pluginutils/event/Event.class b/target/classes/com/exortions/pluginutils/event/Event.class new file mode 100644 index 0000000..1512607 Binary files /dev/null and b/target/classes/com/exortions/pluginutils/event/Event.class differ diff --git a/target/classes/com/exortions/pluginutils/string/StringUtils.class b/target/classes/com/exortions/pluginutils/string/StringUtils.class new file mode 100644 index 0000000..d6e6d2c Binary files /dev/null and b/target/classes/com/exortions/pluginutils/string/StringUtils.class differ diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index cacb53d..0c5b8d1 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -23,6 +23,7 @@ com\exortions\pluginutils\database\SQLDatabase.class com\exortions\pluginutils\mojang\SkinUtils.class com\exortions\pluginutils\database\mysql\MySQLData.class com\exortions\pluginutils\example\commands\HologramCommand.class +com\exortions\pluginutils\database\MySQLResultSetUtils.class com\exortions\pluginutils\example\listeners\EventListener$2.class com\exortions\pluginutils\example\commands\HealCommand.class com\exortions\pluginutils\command\PluginCommand.class