File tree Expand file tree Collapse file tree
jdbc-check-connection/oracle-connection-check/src/main/java/tools/checker Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments