@@ -59,7 +59,7 @@ public void createTable(String name, String... args) {
5959 }
6060 sql .append (")" );
6161 executeStatement (statement , sql .toString ());
62- logger .note ("Table created successfully." );
62+ logger .debug ("Table created successfully." );
6363 } catch (SQLException e ) {
6464 throw new RuntimeException (e );
6565 }
@@ -71,13 +71,13 @@ public void deleteTable(String tableName) {
7171 Statement statement = connection .createStatement ()) {
7272
7373 statement .execute (sql );
74- logger .note ("Table '" + tableName + "' deleted successfully." );
74+ logger .debug ("Table '" + tableName + "' deleted successfully." );
7575 } catch (SQLException e ) {
7676 logger .exception (e );
7777 }
7878 }
7979 public void executeStatement (Statement statement , String sql ) {
80- logger .note ("Executing SQL Statement: " + sql );
80+ logger .debug ("Executing SQL Statement: " + sql );
8181 try {
8282 statement .execute (sql );
8383 } catch (Exception ignored ) {}
@@ -98,30 +98,30 @@ public void displayTableData(String tableName) {
9898
9999 // Print column names
100100 for (int i = 1 ; i <= columnCount ; i ++) {
101- logger .note (metaData .getColumnName (i ) + "\t " );
101+ logger .debug (metaData .getColumnName (i ) + "\t " );
102102 }
103- logger .note ("" );
103+ logger .debug ("" );
104104
105105 // Print table data
106106 while (resultSet .next ()) {
107107 for (int i = 1 ; i <= columnCount ; i ++) {
108- logger .note (resultSet .getString (i ) + "\t " );
108+ logger .debug (resultSet .getString (i ) + "\t " );
109109 }
110- logger .note ("" );
110+ logger .debug ("" );
111111 }
112112 } catch (SQLException e ) {
113113 logger .exception (e );
114114 }
115115 }
116- public List <String > quickSelectData (String name , String select , String ... args ) {
116+ public List <String > selectData (String name , String select , String ... args ) {
117117 StringBuilder sql = new StringBuilder ("SELECT " + select + " FROM " + name + " WHERE " );
118118 for (int i = 0 ; i < args .length ; i += 2 ) {
119119 sql .append (args [i ]).append (" = ?" );
120120 if (i < args .length - 2 ) {
121121 sql .append (" AND " );
122122 }
123123 }
124- logger .note ("Executing SQL Statement: " + sql );
124+ logger .debug ("Executing SQL Statement: " + sql );
125125 List <String > result = new ArrayList <>();
126126 try (Connection connection = getConnection ()) {
127127 PreparedStatement statement = prepareStatement (connection , sql .toString ());
@@ -146,32 +146,6 @@ private PreparedStatement prepareStatement(Connection connection, String sql) {
146146 throw new RuntimeException (e );
147147 }
148148 }
149- public List <String > selectData (String name , String select , String ... args ) {
150- StringBuilder sql = new StringBuilder ("SELECT " + select + " FROM " + name + " WHERE " );
151- for (int i = 0 ; i < args .length ; i +=2 ) {
152- sql .append (args [i ]).append (" = ?" );
153- if (i < args .length - 2 ) {
154- sql .append (" AND " );
155- }
156- }
157- List <String > result = new ArrayList <>();
158- logger .note ("Selecting SQL Statement: " + sql );
159- try (Connection connection = getConnection ();
160- PreparedStatement statement = connection .prepareStatement (
161- sql .toString ())) {
162- for (int i = 2 ; i <= args .length ; i +=2 ) {
163- statement .setString (i /2 , args [i -1 ]);
164- }
165- ResultSet resultSet = statement .executeQuery ();
166-
167- while (resultSet .next ()) {
168- result .add (resultSet .getString (select ));
169- }
170- } catch (SQLException e ) {
171- throw new RuntimeException (e );
172- }
173- return result ;
174- }
175149 public void insertData (String name , String ... args ) {
176150 StringBuilder sql = new StringBuilder ("INSERT INTO " + name + " (" );
177151 for (int i = 0 ; i < args .length ; i +=2 ) {
@@ -188,7 +162,7 @@ public void insertData(String name, String... args) {
188162 }
189163 }
190164 sql .append (")" );
191- logger .note ("Executing SQL Statement: " + sql );
165+ logger .debug ("Executing SQL Statement: " + sql );
192166 try (Connection connection = getConnection ();
193167 PreparedStatement statement = connection .prepareStatement (
194168 sql .toString ())) {
@@ -197,7 +171,7 @@ public void insertData(String name, String... args) {
197171 }
198172 int rowsInserted = statement .executeUpdate ();
199173 if (rowsInserted > 0 ) {
200- logger .note ("A new " + name .substring (0 , name .length ()-1 ) + " was inserted successfully!" );
174+ logger .debug ("A new " + name .substring (0 , name .length ()-1 ) + " was inserted successfully!" );
201175 }
202176 } catch (SQLException e ) {
203177 throw new RuntimeException (e );
@@ -213,7 +187,7 @@ public void updateData(String name, String primaryKey, String primaryKeyValue, S
213187 }
214188 sql .append (" WHERE " ).append (primaryKey ).append (" = ?" );
215189
216- logger .note ("Executing SQL Statement: " + sql );
190+ logger .debug ("Executing SQL Statement: " + sql );
217191 try (Connection connection = getConnection ();
218192 PreparedStatement statement = connection .prepareStatement (sql .toString ())) {
219193 int paramIndex = 1 ;
@@ -224,9 +198,9 @@ public void updateData(String name, String primaryKey, String primaryKeyValue, S
224198
225199 int rowsUpdated = statement .executeUpdate ();
226200 if (rowsUpdated > 0 ) {
227- logger .note ("Data in " + name + " table updated successfully!" );
201+ logger .debug ("Data in " + name + " table updated successfully!" );
228202 } else {
229- logger .note ("No rows were updated." );
203+ logger .debug ("No rows were updated." );
230204 }
231205 } catch (SQLException e ) {
232206 throw new RuntimeException (e );
0 commit comments