Home > Articles

  • Print
  • + Share This
Like this article? We recommend

Derby Application Startup

Listing 4 illustrates the command line argument parsing procedure.

Listing 4 Starting up the program

private void parseArguments(String[] args)
  int length = args.length;
  for (int index = 0; index < length; index++)
    if (args[index].equalsIgnoreCase("jccjdbcclient"))
      framework = "jccjdbc";
      driver = "com.ibm.db2.jcc.DB2Driver";
      protocol = "jdbc:derby:net://localhost:1527/";
    if (args[index].equalsIgnoreCase("derbyclient"))
      framework = "derbyclient";
      driver = "org.apache.derby.jdbc.ClientDriver";
      protocol = "jdbc:derby://localhost:1527/";

The program command line is java SimpleApp, so the above for loop doesn’t execute because the length is zero. This means that the variables: framework, driver, and protocol are all set to default values. These values are set in the public members, as illustrated in Listing 5.

Listing 5 Public member data

public String framework = "embedded";
public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
public String protocol = "jdbc:derby:";

This means that the code in Listing 4 is bypassed. If you prefer, you can supply command-line parameters, but this is an optional step to make it easier to run the example code.

  • + Share This
  • 🔖 Save To Your Account