The doAction( ) method

// A JDBCExamples method to route to the 'action' to be performed

    public static String doAction(String action, Connection con,
 			String locale) 
 		throws Exception {

        String createProcScript =          
             " create proc inoutproc @id int, @newname varchar(50), 
 			@newhome Address, " 
           + "   @oldname varchar(50) output,  @oldhome Address 
 			output as " 
           + " select @oldname = name, @oldhome = home from xmp 
 			where id=@id "
           + " update xmp set name=@newname, home = @newhome 
 			where id=@id ";
        String createTableScript =
 		" create  table xmp (id int, name varchar(50), 
 			home Address)" ;

        String dropTableScript = "drop   table xmp  ";
        String dropProcScript = "drop  proc inoutproc ";
	   String insertScript = "insert  into xmp " 
 		+ "values (1, 'Joe Smith', new Address('987 Shore',
 		'12345'))";

        String workString = "Action (" + action + ) ;
        if (action.equals("connect")) {
             workString += "performed";
        } else if (action.equals("createtable")) {
             workString += doSQL(con, createTableScript );
        } else if (action.equals("createproc")) {
             if (locale.equals(server))  {
                 throw new exception (CreateProc cannot be performed
 				in the server);
             }  else {
                 workString += doSQL(con, createProcScript );
             }
        } else if (action.equals("droptable")) {
             workString += doSQL(con, dropTableScript );
        } else if (action.equals("dropproc")) {
             if (locale.equals(server))  {
                 throw new exception (CreateProc cannot be performed
 				in the server);
             }  else {
                 workString += doSQL(con, dropProcScript );
             }
        } else if (action.equals("insert")) {
             workString += doSQL(con, insertScript );
        } else if (action.equals("update")) {
             workString += updateAction(con); 
        } else if (action.equals("select")) {
             workString += selectAction(con);
        } else if (action.equals("call")) {
             workString += callAction(con);
        } else { return "Invalid action:  " + action ;
        }                   
        return workString;
    }