Actions
AddTable JAVA¶
/**
* Add table to synchronization
* @param tableName table name
* @throws Exception
*/
public void addSynchrnizedTable(String tableName) throws Exception {
HttpURLConnection connection = null;
InputStream resultStream = null;
String resultString = null;
String requestUrl = String.format("%s/AddTable/%s", _serverURL, tableName);
try {
connection = (HttpURLConnection) new URL(requestUrl).openConnection();
int status = connection.getResponseCode();
switch (status){
case HttpURLConnection.HTTP_OK:
resultStream = connection.getInputStream();
resultString = IOUtils.toString(resultStream, "UTF-8");
break;
default:
resultStream = connection.getErrorStream();
resultString = IOUtils.toString(resultStream, "UTF-8");
throw new Exception(resultString);
}
}
finally {
if (resultStream != null) {
try {
resultStream.close();
} catch (IOException e) {
}
}
if (connection != null) {
connection.disconnect();
}
}
}
Updated by Tomek Dziemidowicz over 5 years ago · 1 revisions
Go to top