Skip to content

Commit 4b67ca3

Browse files
authored
Create OracleConnectionCheck.groovy
1 parent 942eb2a commit 4b67ca3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@GrabConfig(systemClassLoader=true)
2+
@Grab('com.oracle.database.jdbc:ojdbc8:19.3.0.0')
3+
4+
import groovy.sql.Sql
5+
6+
if (args.length != 4) {
7+
println "Usage: groovy OracleConnectionCheck.groovy <url> <user> <password> <driver>"
8+
System.exit(1)
9+
}
10+
11+
def url = args[0]
12+
def user = args[1]
13+
def password = args[2]
14+
def driver = args[3]
15+
16+
try {
17+
def sql = Sql.newInstance(url, user, password, driver)
18+
println 'Connection successful!'
19+
sql.close()
20+
} catch (Exception e) {
21+
println "Connection failed: ${e.message}"
22+
}

0 commit comments

Comments
 (0)