Handle NumberFormatException thrown in DatabaseImportController
* Handle NumberFormatException thrown in DatabaseImportController
* Update extensions/database/src/com/google/refine/extension/database/DatabaseImportController.java
* Update DatabaseImportController.java
Add space just before the catch block
@@ -450,7 +450,11 @@ public class DatabaseImportController implements ImportingController {
jdbcConfig.setConnectionName(request.getParameter("connectionName"));
jdbcConfig.setDatabaseType(request.getParameter("databaseType"));
jdbcConfig.setDatabaseHost(request.getParameter("databaseServer"));
+ try {
jdbcConfig.setDatabasePort(Integer.parseInt(request.getParameter("databasePort")));
+ } catch(NumberFormatException nfE) {
+ logger.error("getQueryInfo :: invalid database port ::{}", nfE);
+ }
jdbcConfig.setDatabaseUser(request.getParameter("databaseUser"));
jdbcConfig.setDatabasePassword(request.getParameter("databasePassword"));
jdbcConfig.setDatabaseName(request.getParameter("initialDatabase"));
@@ -462,7 +466,7 @@ public class DatabaseImportController implements ImportingController {
}
if (jdbcConfig.getDatabaseHost() == null || jdbcConfig.getDatabaseName() == null
|| jdbcConfig.getDatabasePassword() == null || jdbcConfig.getDatabaseType() == null
- || jdbcConfig.getDatabaseUser() == null || query == null) {
+ || jdbcConfig.getDatabaseUser() == null || query == null || jdbcConfig.getDatabasePort() == 0) {
if(logger.isDebugEnabled()) {
logger.debug("Missing Database Configuration::{}", jdbcConfig);
}
