public static void main( String[] args ) throws ClassNotFoundException, SQLException, IOException {

        Class.forName("org.h2.Driver");

        try(Connection connection = DriverManager.getConnection("jdbc:h2:mem:mydatabase","user1","password1")){

            // Creation of the table
            String tableName = "posts";
            String firstColumnName = "ID";
            String secColumnName = "postDate";
            String thirdColumnName = "postMessage";

            String tableCreation = "CREATE TABLE "+tableName+"(" +
                            firstColumnName+" INT AUTO_INCREMENT," +
                            secColumnName +" TIMESTAMP," +
                            thirdColumnName +" VARCHAR(1000)" +
                            ")";
            Statement stat1 = connection.createStatement();
            stat1.execute(tableCreation);
         //   stat1.close();

            GuestBookController myGuestBook =
                    new GuestBook(connection,tableName,firstColumnName,secColumnName,thirdColumnName);

            InputStream in = System.in;
            Scanner sc = new Scanner(in);
            while (sc.hasNextLine()){
                String userInput = sc.nextLine();
                if (!userInput.equals("quit")){
                    String[] mas = userInput.split(" ");
// strange way to use enum in switch
                    try{
                        Commands cmd = Commands.valueOf(mas[0].toUpperCase());
                        switch (cmd){
                            case ADD:
                                StringBuilder message = new StringBuilder();
                                for (int i=1;i<mas.length;i++){
                                    message = message.append(mas[i]).append(" ");
                                }
                                myGuestBook.addMessage(message.toString());
                                break;
                            case LIST:
                                List<Record> records = myGuestBook.getRecords();
                                for (Record r:records){
                                    System.out.println("id = " + r.getId() + ", Date = " + r.getPostDate());
                                    System.out.println(r.getPostMessage());
                                }
                                break;
                            default:
                                System.err.println("Unknown command.");
                        }
                    }catch(IllegalArgumentException e){
                        System.err.println("Unknown command.");
                        //e.printStackTrace();
                    }


/*                    switch (mas[0].toUpperCase()){
                        case "ADD":
                            StringBuilder message = new StringBuilder();
                            for (int i=1;i<mas.length;i++){
                                message = message.append(mas[i]).append(" ");
                            }
                            myGuestBook.addMessage(message.toString());
                            break;
                        case "LIST":
                            List<Record> records = myGuestBook.getRecords();
                            for (Record r:records){
                                System.out.println("Record #" + r.getId() + ". Time: " + formatDate(r.getPostDate()));
                                System.out.println(" - "+r.getPostMessage());
                            }
                            break;
                        default:
                            System.err.println("Unknown command.");

                    }
*/
                }else{
                    System.out.println("exit");
                //    System.exit(0);
                    break;
                }
            }
        }
    }