Skip to content

Commit

Permalink
v1.1 - changes:
Browse files Browse the repository at this point in the history
- Closing JDBC connection after test has been completed.
- Increase connection timeout to from 8s to 10s
  • Loading branch information
aimtiaz11 committed Feb 12, 2021
1 parent 4c8c2bd commit cdcdcab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The application connects to the Oracle database and executes a single SQL query:

If it cannot connect for whatever reason, it will fail by logging an error message.

There is a hardcoded connection timeout set to 8 seconds.
There is a hardcoded connection timeout set to 10 seconds.

## License

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.aimtiaz</groupId>
<artifactId>jdbc-tester</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<parent>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void main(String[] args) throws ClassNotFoundException {
Properties properties = new Properties();
properties.setProperty("user", args[0]);
properties.setProperty("password", args[1]);
properties.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "8000");
properties.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "10000");

try {
LOG.info("****** Starting JDBC Connection test *******");
Expand All @@ -42,7 +42,10 @@ public static void main(String[] args) throws ClassNotFoundException {
while (resultSet.next()) {
LOG.info("Result of SQL query: [{}]", resultSet.getString(1));
}

statement.close();
conn.close();

LOG.info("JDBC connection test successful!");
} catch (SQLException ex) {
LOG.error("Exception occurred connecting to database: {}", ex.getMessage());
Expand Down

0 comments on commit cdcdcab

Please sign in to comment.