Source:
<code>public static void main(String[] args) { final int maxCryptoKeyLength = getMaxKeyLength(); if (maxCryptoKeyLength < Integer.MAX_VALUE){ System.err.println("WARNING: Cryptographic key length is limited to " + maxCryptoKeyLength + " bits. You probably don't have unlimited strength cryptography installed."); } Parameters config = new Parameters(); config.parse(Client.class.getName(), args); System.out.println("Connecting to VoltDB"); ClientResponse response; try { ClientConfig clientConfig = new ClientConfig(); clientConfig.setTrustStoreConfigFromPropertyFile(config.sslFile); clientConfig.enableSSL(); final Client client = ClientFactory.createClient(clientConfig); StringTokenizer serverParser = new StringTokenizer(config.servers, ","); while (serverParser.hasMoreTokens()){ client.createConnection(serverParser.nextToken(), Client.VOLTDB_SERVER_PORT); } String person = generateName(); try { response = client.callProcedure("@AdHoc", "INSERT INTO people VALUES '" + person + "';"); if (response.getStatus() != ClientResponse.SUCCESS){ throw new RuntimeException("Could not insert " + person + " into the database", null); } System.out.println("Added " + person + " to the database"); } catch (ProcCallException e){ if (e.getMessage().contains("UNIQUE")){ System.out.println(person + " is already in the database"); } else { throw e; } } response = client.callProcedure("@AdHoc", "SELECT * FROM people LIMIT 10;"); if (response.getStatus() != ClientResponse.SUCCESS){ throw new RuntimeException("Could not examine the database"); } VoltTable[] results = response.getResults(); final int nameIndex = results[0].getColumnIndex("name"); System.out.println("\nNames in the database: (limit 10)"); while (results[0].advanceRow()){ System.out.println(results[0].get(nameIndex, VoltType.STRING)); } <START> System.out.println("Success!"); <END> } catch (IOException e) { throw new RuntimeException(e); } catch (ProcCallException e) { throw new RuntimeException(e); } }</code><technical_language>drain close client connection? if examples consistent good practice</technical_language>

Target:
public static void main(String[] args) { final int maxCryptoKeyLength = getMaxKeyLength(); if (maxCryptoKeyLength < Integer.MAX_VALUE){ System.err.println("WARNING: Cryptographic key length is limited to " + maxCryptoKeyLength + " bits. You probably don't have unlimited strength cryptography installed."); } Parameters config = new Parameters(); config.parse(Client.class.getName(), args); System.out.println("Connecting to VoltDB"); try { ClientConfig clientConfig = new ClientConfig(); clientConfig.setTrustStoreConfigFromPropertyFile(config.sslFile); clientConfig.enableSSL(); final Client client = ClientFactory.createClient(clientConfig); StringTokenizer serverParser = new StringTokenizer(config.servers, ","); while (serverParser.hasMoreTokens()){ client.createConnection(serverParser.nextToken(), Client.VOLTDB_SERVER_PORT); } String person = generateName(); ClientResponse response = client.callProcedure("@AdHoc", "INSERT INTO people VALUES '" + person + "';"); if (response.getStatus() != ClientResponse.SUCCESS){ throw new RuntimeException("Could not insert " + person + " into the database", null); } System.out.println("Added " + person + " to the database"); response = client.callProcedure("@AdHoc", "SELECT * FROM people LIMIT 10;"); if (response.getStatus() != ClientResponse.SUCCESS){ throw new RuntimeException("Could not examine the database"); } VoltTable[] results = response.getResults(); final int nameIndex = results[0].getColumnIndex("name"); System.out.println("\nNames in the database: (limit 10)"); while (results[0].advanceRow()){ System.out.println(results[0].get(nameIndex, VoltType.STRING)); } client.drain(); client.close(); System.out.println("Success!"); } catch (IOException e) { throw new RuntimeException(e); } catch (ProcCallException e) { throw new RuntimeException(e); } catch (InterruptedException e){ throw new RuntimeException(e); } }