package Database;

import java.util.*;

public class SqlHandler {
    public static void upadte(String table, Map<String, String> values, String condition) {

    }

    public static void insert(String table, Map<String, String> values) {

    }

    public static void delete(String table, String condition) {

    }

    public static void select(String table, String[] fields, String condition) {

    }
}

@@ -10,17 +10,19 @@
 atabase;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -33,17 +33,39 @@
 .util.*;
-%0A
+%0D%0Aimport java.sql.*;%0D%0A%0D
 %0Apublic 
@@ -82,16 +82,17 @@
 andler %7B
+%0D
 %0A    pub
@@ -179,257 +179,2367 @@
 n) %7B
-%0A%0A    %7D%0A%0A    public static void insert(String table, Map%3CString, String%3E values) %7B%0A%0A    %7D%0A%0A    public static void delete(String table, String condition) %7B%0A%0A    %7D%0A%0A    public static void select(String table, String%5B%5D fields, String condition) %7B%0A%0A    %7D%0A%7D
+%0D%0A    DataSource db = dataSource();%0D%0A    try (Connection connection = dataSource.getConnection()) %7B%0D%0A        Statement stmt = connection.createStatement();%0D%0A        String setValues = %22%22;%0D%0A        for(String key: values.keySet())%0D%0A        %09setValues = setValues + key + %22=%22 + values.get(key) + %22,%22;%0D%0A        setValues = setValue.substring(0,setValues.length()-1);%0D%0A        ResultSet rs = stmt.executeQuery(%22UPDATE%22 + table + %22SET%22 + setValues + %22WHERE%22 + condition);%0D%0A      %7D catch (Exception e) %7B%0D%0A        %0D%0A      %7D%0D%0A    %7D%0D%0A%0D%0A    public static void insert(String table, Map%3CString, String%3E values) %7B%0D%0A        DataSource db = dataSource();%0D%0A        try (Connection connection = dataSource.getConnection()) %7B%0D%0A            Statement stmt = connection.createStatement();%0D%0A            String tcolumns = %22(%22;%0D%0A            String tvalues = %22(%22;%0D%0A            for(String key: values.keySet())%0D%0A            %09tcolumns = tcolumns + key + %22,%22;%0D%0A            tcolumns = tcolumns.substring(0,tcolumns.length()-1) + %22)%22;%0D%0A            for(String key: values.keySet())%0D%0A            %09tvalues = tvalues + values.get(key) + %22,%22;%0D%0A            tvalues = tvalues.substring(0,tvalues.length()-1) + %22)%22;%0D%0A            ResultSet rs = stmt.executeQuery(%22INSERT INTO%22 + table + tcolumns + %22VALUES%22 + tvalues);%0D%0A          %7D catch (Exception e) %7B%0D%0A            %0D%0A          %7D%0D%0A%0D%0A    %7D%0D%0A%0D%0A    public static void delete(String table, String condition) %7B%0D%0A        DataSource db = dataSource();%0D%0A        try (Connection connection = dataSource.getConnection()) %7B%0D%0A            Statement stmt = connection.createStatement();%0D%0A            ResultSet rs = stmt.executeQuery(%22DELETE FROM%22 + table + %22WHERE%22 + condition);%0D%0A          %7D catch (Exception e) %7B%0D%0A            %0D%0A          %7D%0D%0A%0D%0A    %7D%0D%0A%0D%0A    public static void select(String table, String%5B%5D fields, String condition) %7B%0D%0A    %09DataSource db = dataSource();%0D%0A        try (Connection connection = dataSource.getConnection()) %7B%0D%0A            Statement stmt = connection.createStatement();%0D%0A            String columns = %22%22;%0D%0A            for (String field : fields)%0D%0A            %09columns = columns + field + %22,%22;%0D%0A            columns = columns.substring(0,columns.length()-1);%0D%0A            ResultSet rs = stmt.executeQuery(%22SELECT%22 + columns + %22FROM%22 + table + %22WHERE%22 + condition);%0D%0A          %7D catch (Exception e) %7B%0D%0A            %0D%0A          %7D%0D%0A%0D%0A    %7D%0D%0A%7D%0D
 %0A

add functions to sqlhandler