I am told that i do not need the JDBC connector. I have the database endpoint. I am making a JDBC call but am not able to connect to the DB. The piece of code that I have written is as follows:
package com.test;
import java.sql.*;
public class Test {
public static void main(String[] args) {
String host = "jdbc:mysql://myaddress.us-west-2.rds.amazonaws.com";
String uName = "admin";
String uPass = "admin";
System.out.println("-------- MySQL JDBC Connection Demo ------------");
try
{
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
System.out.println("MySQL JDBC Driver not found !!");
return;
}
System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;
try {
connection = DriverManager
.getConnection(host, uName, uPass);
System.out.println("SQL Connection to database established!");
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
return;
} finally {
try
{
if(connection != null)
connection.close();
System.out.println("Connection closed !!");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}