Skip to content

Commit e8102db

Browse files
authored
connection checker
1 parent e2ea153 commit e8102db

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • jdbc-check-connection/oracle-connection-check/src/main/java/tools/checker
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package tools.checker;
2+
3+
import java.sql.Connection;
4+
import java.sql.DriverManager;
5+
import java.sql.SQLException;
6+
7+
public class App {
8+
public static void main(String[] args) {
9+
if (args.length != 4) {
10+
System.out.println("Usage: java OracleConnectionCheck <url> <user> <password> <driver>");
11+
System.exit(1);
12+
}
13+
14+
String url = args[0];
15+
String user = args[1];
16+
String password = args[2];
17+
String driver = args[3];
18+
19+
try {
20+
Class.forName(driver);
21+
Connection connection = DriverManager.getConnection(url, user, password);
22+
System.out.println("Connection successful!");
23+
connection.close();
24+
} catch (ClassNotFoundException e) {
25+
System.out.println("Oracle JDBC Driver not found: " + e.getMessage());
26+
} catch (SQLException e) {
27+
System.out.println("Connection failed: " + e.getMessage());
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)