import java.util.InputMismatchException;
import java.util.Scanner;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

public class Main {

    private static final Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {

        try {

            Class.forName("oracle.jdbc.driver.OracleDriver");

        } catch (ClassNotFoundException e) {

            System.out.println("Oracle JDBC Driver not found!");
            e.printStackTrace();
            return;

        }

        System.out.println("Oracle JDBC Driver registered!");

        Connection connection = null;

        try {

            connection = DriverManager.getConnection(
                    "jdbc:oracle:thin:@toldb.oulu.fi:1521:toldb11", "STU31", "delrix123");

        } catch (SQLException e) {

            System.out.println("Connection failed!");
            e.printStackTrace();
            return;

        }

        if (connection != null) {

            System.out.println("Connection to database successful!");

        } else {

            System.out.println("Failed to make connection!");

        }

        System.out.print("\n\n");
        System.out.println("1: Show items.");
        System.out.println("2: Show customers.");
        System.out.println("Make selection and press ENTER.");

        switch (getUserInput()) {

            case 1:
                showItems();
                break;

            case 2:
                showCustomers();
                break;
        }

        try {

            connection.close();

        } catch (SQLException e) {

            System.out.println("Error while closing connection!");
            e.printStackTrace();

        }
    }

    private static int getUserInput() {

        int choice = 0;

        while (true) {

            try {

                choice = scan.nextInt();
                if (choice != 1 && choice != 2) {

                    scan.nextLine();
                    System.out.println("Please select 1 or 2.");

                } else {

                    scan.nextLine();
                    break;

                }

            } catch (InputMismatchException ime) {

                System.out.println("Please select 1 or 2.");
                scan.nextLine();

            }
        }

        return choice;
    }

    private static void showCustomers() {

    }

    private static void showItems() {

    }
}
@@ -508,38 +508,46 @@
 ();%0A            
-return
+System.exit(0)
 ;%0A%0A        %7D%0A%0A  
@@ -942,22 +942,30 @@
         
-return
+System.exit(0)
 ;%0A%0A     
@@ -1151,24 +1151,52 @@
 nnection!%22);
+%0A            System.exit(0);
 %0A%0A        %7D%0A
@@ -1322,24 +1322,64 @@
 stomers.%22);%0A
+        System.out.println(%223: Exit.%22);%0A
         Syst
@@ -1613,16 +1613,431 @@
   break;
+%0A%0A            case 3:%0A                try %7B%0A%0A                    connection.close();%0A                    System.exit(0);%0A%0A                %7D catch (SQLException e) %7B%0A%0A                    System.out.println(%22Error while closing connection!%22);%0A                    e.printStackTrace();%0A%0A                %7D%0A%0A            default:%0A                System.out.println(%22Something went wrong!%22);%0A                System.exit(1);
 %0A       
@@ -2082,24 +2082,52 @@
 ion.close();
+%0A            System.exit(0);
 %0A%0A        %7D 
@@ -2416,24 +2416,25 @@
 .nextInt();%0A
+%0A
             
@@ -2467,16 +2467,31 @@
 ice != 2
+ && choice != 3
 ) %7B%0A%0A   
@@ -2575,29 +2575,32 @@
 ase select 1
+, 2
  or 
-2
+3
 .%22);%0A%0A      
@@ -2810,13 +2810,16 @@
 ct 1
+, 2
  or 
-2
+3
 .%22);

exit routine