Forum Discussion
manthena2020
2 years agoAdvisor
import groovy.sql.Sql
import java.sql.SQLException
// Register the Sybase driver
Class.forName("com.sybase.jdbc4.jdbc.SybDriver")
// Get basic info to connect
def hostname = hostProps.get("system.hostname")
def user = hostProps.get("sybase.user")
def pass = hostProps.get("sybase.pass")
def port = 21000
def wildvalue = instanceProps.get("wildvalue")
def url = "jdbc:sybase:Tds:" + hostname + ":21000"
def driver = "com.sybase.jdbc4.jdbc.SybDriver"
def sql = Sql.newInstance(url, user, pass, driver)
// Check Sybase server status
return_code = 0
try {
sql.getConnection()
} catch (SQLException e) {
if (e.getMessage().contains("Login failed")) {
return_code = 1 // Invalid password or login failed
} else {
return_code = 2 // Other connection or server error, including server offline
}
} finally {
sql.close()
return return_code
}
i am getting 0 , even for Login failed as well as. Please look into it
Related Content
- 6 months ago