I am trying to establish a connectio to Vertica in order to run a simple query for testing the successfull connection. Although the my R script below seems to run properly, the connection fails and the sql query does not run.
library(RJDBC)
# Path to the uploaded Vertica JDBC driver JAR file
jdbc_driver_path <- "/cloud/project/vertica-jdbc-24.2.0-1.jar"
# Load the JDBC driver
drv <- JDBC(driverClass = "com.vertica.jdbc.Driver", classPath = jdbc_driver_path)
# Database connection details
jdbc_url <- "jdbc:vertica://"my_host (ip of one node of my cluster)":my_port(5450)/my_database_name(verticadb)"
username <- "my_username"
password <- "my_password"
# Try to establish the connection and catch any errors
conn <- tryCatch({
dbConnect(drv, jdbc_url, username, password)
}, error = function(e) {
cat("Error: ", e$message, "\n")
NULL
})
# Check if the connection was successful
if (!is.null(conn)) {
# Execute a query
result <- dbGetQuery(conn, "SELECT * FROM shema_name.table_name LIMIT 10")
# Print the result
print(result)
# Close the connection
dbDisconnect(conn)
} else {
cat("Failed to connect to the database.\n")
}
The error appears is
Failed to connect to /"my_host"
Error: Unable to connect JDBC to jdbc:vertica://"my_host":5450/verticadb
JDBC ERROR: [Vertica][VJDBC](100176) Failed to connect to host "my_host" on port 5450. Reason: Failed to establish a connection to the primary server or any backup address due to network error
Anyone that has any suggestions?
My final goal is the data migration from a database to Vertica
Thanks in advance!