Skip to content

Commit

Permalink
#389: Improved connection error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko committed Sep 28, 2020
1 parent 5835b8d commit 3bd6632
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 30 deletions.
3 changes: 2 additions & 1 deletion doc/changes/changes_4.0.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Code name:
## Refactoring

* #263: Removed SybaseMetadataReader class as it was not used by the dialect.
* #381: Migrated from version.sh to artifact-reference-checker-maven-plugin
* #381: Migrated from version.sh to artifact-reference-checker-maven-plugin.
* #389: Improved connection error handling.

## Dependency updates

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.exasol.adapter.dialects.athena;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
import static com.exasol.adapter.capabilities.PredicateCapability.*;
import static com.exasol.adapter.capabilities.ScalarFunctionCapability.*;

import java.sql.SQLException;
import java.util.*;
import java.util.Set;

import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.capabilities.Capabilities;
Expand Down Expand Up @@ -138,7 +139,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new AthenaMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Athena remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Athena remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.bigquery;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -45,7 +46,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new BigQueryMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create BigQuery remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create BigQuery remote metadata reader. Caused by: " + exception.getMessage(),
exception);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new DB2MetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create DB2 remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create DB2 remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.exasol.adapter.dialects.generic;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;

import java.sql.SQLException;
import java.util.*;
import java.util.Set;

import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.adapternotes.SchemaAdapterNotes;
Expand Down Expand Up @@ -87,7 +88,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
return new GenericMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException(
"Unable to create remote metadata reader for the generic SQL dialect.", exception);
"Unable to create remote metadata reader for the generic SQL dialect. Caused by: "
+ exception.getMessage(),
exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.hive;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -123,7 +124,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new HiveMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Hive remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Hive remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.impala;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -121,7 +122,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new ImpalaMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Impala remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Impala remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new MySqlMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create MySQL remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create MySQL remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.oracle;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.IS_LOCAL_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -152,7 +153,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new OracleMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Oracle remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Oracle remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new PostgreSQLMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create PostgreSQL remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create PostgreSQL remote metadata reader. Caused by: " + exception.getMessage(),
exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.redshift;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -121,7 +122,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new RedshiftMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Redshift remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Redshift remote metadata reader. Caused by: " + exception.getMessage(),
exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.saphana;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -120,7 +121,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new SapHanaMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create HANA remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create HANA remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.sqlserver;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -135,7 +136,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new SqlServerMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create SQL Server remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create SQL Server remote metadata reader. Caused by: " + exception.getMessage(),
exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.exasol.adapter.dialects.sybase;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.CATALOG_NAME_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;
import static com.exasol.adapter.capabilities.AggregateFunctionCapability.*;
import static com.exasol.adapter.capabilities.LiteralCapability.*;
import static com.exasol.adapter.capabilities.MainCapability.*;
Expand Down Expand Up @@ -136,7 +137,8 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new BaseRemoteMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Sybase remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Sybase remote metadata reader. Caused by: " + exception.getMessage(), exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new TeradataMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create Teradata remote metadata reader.", exception);
throw new RemoteMetadataReaderException(
"Unable to create Teradata remote metadata reader. Caused by: " + exception.getMessage(),
exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.exasol.adapter.dialects.dummy;

import static com.exasol.adapter.AdapterProperties.*;
import static com.exasol.adapter.AdapterProperties.EXCEPTION_HANDLING_PROPERTY;
import static com.exasol.adapter.AdapterProperties.SCHEMA_NAME_PROPERTY;

import java.sql.SQLException;
import java.util.*;
import java.util.Set;

import com.exasol.adapter.AdapterProperties;
import com.exasol.adapter.capabilities.Capabilities;
Expand Down Expand Up @@ -66,7 +67,9 @@ protected RemoteMetadataReader createRemoteMetadataReader() {
try {
return new BaseRemoteMetadataReader(this.connectionFactory.getConnection(), this.properties);
} catch (final SQLException exception) {
throw new RemoteMetadataReaderException("Unable to create remote metadata reader for the Dummy dialect.",
throw new RemoteMetadataReaderException(
"Unable to create remote metadata reader for the Dummy dialect. Caused by: "
+ exception.getMessage(),
exception);
}
}
Expand Down

0 comments on commit 3bd6632

Please sign in to comment.