Skip to content

Commit ea013b0

Browse files
Changed errors for dropping tables to info messages
git-svn-id: http://webgoat.googlecode.com/svn/trunk@468 4033779f-a91e-0410-96ef-6bf7bf53c507
1 parent c5f8b99 commit ea013b0

File tree

1 file changed

+33
-44
lines changed

1 file changed

+33
-44
lines changed

webgoat/src/main/java/org/owasp/webgoat/session/CreateDB.java

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void createMessageTable(Connection connection) throws SQLException
5959
statement.executeUpdate(dropTable);
6060
} catch (SQLException e)
6161
{
62-
System.out.println("Error dropping message database");
62+
System.out.println("Info - Could not drop message database");
6363
}
6464

6565
// Create the new table
@@ -71,8 +71,7 @@ private void createMessageTable(Connection connection) throws SQLException
7171
statement.executeUpdate(createTableStatement);
7272
} catch (SQLException e)
7373
{
74-
System.out.println("Error creating message database");
75-
e.printStackTrace();
74+
System.out.println("Error creating message database " + e.getLocalizedMessage());
7675
}
7776
}
7877

@@ -95,7 +94,7 @@ private void createMFEImagesTable(Connection connection) throws SQLException
9594
}
9695
catch (SQLException e)
9796
{
98-
System.out.println("Error dropping mfe_images table from database");
97+
System.out.println("Info - Could not drop mfe_images table from database");
9998
}
10099

101100
// Create the new mfe_images table
@@ -109,8 +108,7 @@ private void createMFEImagesTable(Connection connection) throws SQLException
109108
}
110109
catch (SQLException e)
111110
{
112-
System.out.println("Error creating mfe_images table in database");
113-
e.printStackTrace();
111+
System.out.println("Error creating mfe_images table in database " + e.getLocalizedMessage());
114112
}
115113

116114
}
@@ -135,7 +133,7 @@ private void createProductTable(Connection connection) throws SQLException
135133
statement.executeUpdate(dropTable);
136134
} catch (SQLException e)
137135
{
138-
System.out.println("Error dropping product database");
136+
System.out.println("Info - Could not drop product table");
139137
}
140138

141139
// Create the new table
@@ -147,8 +145,7 @@ private void createProductTable(Connection connection) throws SQLException
147145
statement.executeUpdate(createTableStatement);
148146
} catch (SQLException e)
149147
{
150-
System.out.println("Error creating product database");
151-
e.printStackTrace();
148+
System.out.println("Error creating product table " + e.getLocalizedMessage());
152149
}
153150

154151
// Populate
@@ -184,7 +181,7 @@ private void createUserAdminTable(Connection connection) throws SQLException
184181
statement.executeUpdate(dropTable);
185182
} catch (SQLException e)
186183
{
187-
System.out.println("Error dropping user admin database");
184+
System.out.println("Info - Could not drop user admin table");
188185
}
189186

190187
// Create the new table
@@ -195,8 +192,7 @@ private void createUserAdminTable(Connection connection) throws SQLException
195192
statement.executeUpdate(createTableStatement);
196193
} catch (SQLException e)
197194
{
198-
System.out.println("Error creating user admin database");
199-
e.printStackTrace();
195+
System.out.println("Error creating user admin table " + e.getLocalizedMessage());
200196
}
201197

202198
// Populate
@@ -232,7 +228,7 @@ private void createUserDataTable(Connection connection) throws SQLException
232228
statement.executeUpdate(dropTable);
233229
} catch (SQLException e)
234230
{
235-
System.out.println("Error dropping user database");
231+
System.out.println("Info - Could not drop user table");
236232
}
237233

238234
// Create the new table
@@ -244,8 +240,7 @@ private void createUserDataTable(Connection connection) throws SQLException
244240
statement.executeUpdate(createTableStatement);
245241
} catch (SQLException e)
246242
{
247-
System.out.println("Error creating user database");
248-
e.printStackTrace();
243+
System.out.println("Error creating user table " + e.getLocalizedMessage());
249244
}
250245

251246
// Populate it
@@ -289,7 +284,7 @@ private void createLoginTable(Connection connection) throws SQLException
289284
statement.executeUpdate(dropTable);
290285
} catch (SQLException e)
291286
{
292-
System.out.println("Error dropping user_login table");
287+
System.out.println("Info - Could not drop user_login table");
293288
}
294289

295290
// Create the new table
@@ -300,8 +295,7 @@ private void createLoginTable(Connection connection) throws SQLException
300295
statement.executeUpdate(createTableStatement);
301296
} catch (SQLException e)
302297
{
303-
System.out.println("Error creating user database");
304-
e.printStackTrace();
298+
System.out.println("Error creating user_login table " + e.getLocalizedMessage());
305299
}
306300

307301
}
@@ -319,7 +313,7 @@ private void createBlindSQLLessonTable(Connection connection) throws SQLExceptio
319313
}
320314
catch (SQLException e)
321315
{
322-
System.out.println("Error dropping pins table");
316+
System.out.println("Info - Could not drop pins table");
323317
}
324318

325319
// Create the new table
@@ -334,8 +328,7 @@ private void createBlindSQLLessonTable(Connection connection) throws SQLExceptio
334328
}
335329
catch (SQLException e)
336330
{
337-
System.out.println("Error creating pins table");
338-
e.printStackTrace();
331+
System.out.println("Error creating pins table " + e.getLocalizedMessage());
339332
}
340333

341334
// Populate it
@@ -367,7 +360,7 @@ private void createModifyWithSQLLessonTable(Connection connection) throws SQLExc
367360
}
368361
catch (SQLException e)
369362
{
370-
System.out.println("Error dropping salaries table");
363+
System.out.println("Info - Could not drop salaries table");
371364
}
372365

373366
// Create the new table
@@ -381,8 +374,7 @@ private void createModifyWithSQLLessonTable(Connection connection) throws SQLExc
381374
}
382375
catch (SQLException e)
383376
{
384-
System.out.println("Error creating salaries table");
385-
e.printStackTrace();
377+
System.out.println("Error creating salaries table " + e.getLocalizedMessage());
386378
}
387379

388380
// Populate it
@@ -420,7 +412,7 @@ private void createWeatherDataTable(Connection connection) throws SQLException
420412
statement.executeUpdate(dropTable);
421413
} catch (SQLException e)
422414
{
423-
System.out.println("Error dropping weather database");
415+
System.out.println("Info - Could not drop weather table");
424416
}
425417

426418
// Create the new table
@@ -432,8 +424,7 @@ private void createWeatherDataTable(Connection connection) throws SQLException
432424
statement.executeUpdate(createTableStatement);
433425
} catch (SQLException e)
434426
{
435-
System.out.println("Error creating weather database");
436-
e.printStackTrace();
427+
System.out.println("Error creating weather table " + e.getLocalizedMessage());
437428
}
438429

439430
// Populate it
@@ -468,7 +459,7 @@ private void createTanUserDataTable(Connection connection) throws SQLException
468459
statement.executeUpdate(dropTable);
469460
} catch (SQLException e)
470461
{
471-
System.out.println("Error dropping user database");
462+
System.out.println("Info - Could not drop user_data_tan table");
472463
}
473464

474465
// Create the new table
@@ -481,8 +472,7 @@ private void createTanUserDataTable(Connection connection) throws SQLException
481472
statement.executeUpdate(createTableStatement);
482473
} catch (SQLException e)
483474
{
484-
System.out.println("Error creating user database");
485-
e.printStackTrace();
475+
System.out.println("Error creating user_data_tan table " + e.getLocalizedMessage());
486476
}
487477

488478
// Populate it
@@ -512,7 +502,7 @@ private void createTanTable(Connection connection) throws SQLException
512502
statement.executeUpdate(dropTable);
513503
} catch (SQLException e)
514504
{
515-
System.out.println("Error dropping tan database");
505+
System.out.println("Info - Could not drop tan table");
516506
}
517507

518508
// Create the new table
@@ -523,8 +513,7 @@ private void createTanTable(Connection connection) throws SQLException
523513
statement.executeUpdate(createTableStatement);
524514
} catch (SQLException e)
525515
{
526-
System.out.println("Error creating tan database");
527-
e.printStackTrace();
516+
System.out.println("Error creating tan table " + e.getLocalizedMessage());
528517
}
529518

530519
// Populate it
@@ -574,7 +563,7 @@ private void createEmployeeTable(Connection connection) throws SQLException
574563
statement.executeUpdate(dropTable);
575564
} catch (SQLException e)
576565
{
577-
System.out.println("Error: unable to drop employee table");
566+
System.out.println("Info - Could not drop employee table");
578567
}
579568

580569
// Create Table
@@ -596,7 +585,7 @@ private void createEmployeeTable(Connection connection) throws SQLException
596585
statement.executeUpdate(createTable);
597586
} catch (SQLException e)
598587
{
599-
System.out.println("Error: unable to create employee table");
588+
System.out.println("Error: unable to create employee table " + e.getLocalizedMessage());
600589
}
601590

602591
String insertData1 = "INSERT INTO employee VALUES (101, 'Larry', 'Stooge', '386-09-5451', 'larry',"
@@ -671,7 +660,7 @@ private void createRolesTable(Connection connection) throws SQLException
671660
statement.executeUpdate(dropTable);
672661
} catch (SQLException e)
673662
{
674-
System.out.println("Error: unable to drop roles");
663+
System.out.println("Info - Could not drop roles table");
675664
}
676665

677666
try
@@ -682,7 +671,7 @@ private void createRolesTable(Connection connection) throws SQLException
682671
statement.executeUpdate(createTable);
683672
} catch (SQLException e)
684673
{
685-
System.out.println("Error: Unable to create role table");
674+
System.out.println("Error: Unable to create role table: " + e.getLocalizedMessage());
686675
}
687676

688677
String insertData1 = "INSERT INTO roles VALUES (101, 'employee')";
@@ -722,7 +711,7 @@ private void createAuthTable(Connection connection) throws SQLException
722711
statement.executeUpdate(dropTable);
723712
} catch (SQLException e)
724713
{
725-
System.out.println("Error: unable to drop auth");
714+
System.out.println("Info - Could not drop auth table");
726715
}
727716

728717
try
@@ -733,7 +722,7 @@ private void createAuthTable(Connection connection) throws SQLException
733722
statement.executeUpdate(createTable);
734723
} catch (SQLException e)
735724
{
736-
System.out.println("Error: unable to create auth table");
725+
System.out.println("Error: unable to create auth table: " + e.getLocalizedMessage());
737726
}
738727

739728
String insertData1 = "INSERT INTO auth VALUES('employee', 'Logout')";
@@ -829,7 +818,7 @@ private void createOwnershipTable(Connection connection) throws SQLException
829818
statement.executeUpdate(dropTable);
830819
} catch (SQLException e)
831820
{
832-
System.out.println("Error: unable to drop ownership");
821+
System.out.println("Info - Could not drop ownership table");
833822
}
834823

835824
try
@@ -840,7 +829,7 @@ private void createOwnershipTable(Connection connection) throws SQLException
840829
statement.executeUpdate(createTable);
841830
} catch (SQLException e)
842831
{
843-
System.out.println("Error: unable to create ownership table");
832+
System.out.println("Error: unable to create ownership table: " + e.getLocalizedMessage());
844833
}
845834

846835
String inputData = "INSERT INTO ownership VALUES (112, 101)";
@@ -973,7 +962,7 @@ private void createTransactionTable(Connection connection) throws SQLException
973962
statement.executeUpdate(dropTable);
974963
} catch (SQLException e)
975964
{
976-
System.out.println("Warning: unable to drop Transactions");
965+
System.out.println("Info - Could not drop transactions table");
977966
}
978967

979968
try
@@ -986,7 +975,7 @@ private void createTransactionTable(Connection connection) throws SQLException
986975
statement.executeUpdate(createTable);
987976
} catch (SQLException e)
988977
{
989-
System.out.println("Error: unable to create Transactions: " + e.getLocalizedMessage());
978+
System.out.println("Error: unable to create transactions table: " + e.getLocalizedMessage());
990979
throw e;
991980
}
992981

@@ -1008,7 +997,7 @@ private void createTransactionTable(Connection connection) throws SQLException
1008997
}
1009998
} catch (SQLException sqle)
1010999
{
1011-
System.out.println("Error: Unable to insert data: " + sqle);
1000+
System.out.println("Error: Unable to insert transactions: " + sqle.getLocalizedMessage());
10121001
int errorCode = sqle.getErrorCode();
10131002
System.out.println("Error Code: " + errorCode);
10141003
// ignore exceptions for Oracle and SQL Server

0 commit comments

Comments
 (0)