Results 1 to 4 of 4
  1. #1
    Archeantus is offline Member
    Join Date
    May 2014
    Posts
    13
    Rep Power
    0

    Default I have an issue connecting to RDS DB from java application

    I have an issue connecting to RDS DB from java application; therefore, I will describe the issue and code.

    1) I'm connecting to an Amazon RDS DB using JDBC and MySQL:
    Java Code:
    public Connection getConnection() {
        Connection conn = null;
        try {Class.forName("com.mysql.jdbc.Driver");} catch (ClassNotFoundException e) {e.printStackTrace();}
        try {conn = DriverManager.getConnection("jdbc:mysql://"+this.host+":"+this.port+"/"+dbname, this.username, this.password);} catch (SQLException e) {e.printStackTrace();}
        return conn;
    }
    In the console it's just waiting to connecting. No errors, no stacktraces, nothing. Until I reboot my DB then it prints an error for a connection time out.

    The error points to this line:
    Java Code:
    try {conn = DriverManager.getConnection("jdbc:mysql://"+this.host+":"+this.port+"/"+dbname, this.username, this.password);} catch (SQLException e) {e.printStackTrace();}
    But I know I did it all right. Is there something that I need or missed when trying to connect to my DB? I have the Connector/J in my build path and in the directory the jar runs in.

  2. #2
    Join Date
    Apr 2014
    Posts
    49
    Rep Power
    0

    Default Re: I have an issue connecting to RDS DB from java application

    Quote Originally Posted by Archeantus View Post
    I have an issue connecting to RDS DB from java application; therefore, I will describe the issue and code.

    1) I'm connecting to an Amazon RDS DB using JDBC and MySQL:
    Java Code:
    public Connection getConnection() {
        Connection conn = null;
        try {Class.forName("com.mysql.jdbc.Driver");} catch (ClassNotFoundException e) {e.printStackTrace();}
        try {conn = DriverManager.getConnection("jdbc:mysql://"+this.host+":"+this.port+"/"+dbname, this.username, this.password);} catch (SQLException e) {e.printStackTrace();}
        return conn;
    }
    In the console it's just waiting to connecting. No errors, no stacktraces, nothing. Until I reboot my DB then it prints an error for a connection time out.

    The error points to this line:
    Java Code:
    try {conn = DriverManager.getConnection("jdbc:mysql://"+this.host+":"+this.port+"/"+dbname, this.username, this.password);} catch (SQLException e) {e.printStackTrace();}
    But I know I did it all right. Is there something that I need or missed when trying to connect to my DB? I have the Connector/J in my build path and in the directory the jar runs in.


    check your database server is running also

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,030
    Rep Power
    6

    Default Re: I have an issue connecting to RDS DB from java application

    Can you connect to the database using MySQL workbench?

    Connection issues such as this are rarely code related, its not like the API designers are out to cause misery for people by including wrong ways to connect that cause the connection to go dead. Its 'something' in the network environment. That's very vague and with a good reason: it can be lots of things and the problem can exist on both your side and "the other side".

    I would rather contact Amazon support rather than trying to find tech support in forums. Their logs should be able to tell you what's happening and more importantly: what's NOT happening.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Archeantus is offline Member
    Join Date
    May 2014
    Posts
    13
    Rep Power
    0

    Default Re: I have an issue connecting to RDS DB from java application

    Yeah I can connect using MySQL workbench. The problem was I forgot to add the IP to the security group.

Similar Threads

  1. Replies: 4
    Last Post: 06-07-2010, 07:26 PM
  2. Java connecting disconneting issue
    By Logi505 in forum New To Java
    Replies: 0
    Last Post: 04-15-2010, 12:14 PM
  3. java application connecting to a server
    By wildheart25c in forum New To Java
    Replies: 2
    Last Post: 09-17-2009, 02:59 AM
  4. connecting a java application to a DB in netbeans
    By kulangotski in forum Advanced Java
    Replies: 4
    Last Post: 03-22-2009, 09:58 AM
  5. Networking Application Issue is connecting
    By andre1011 in forum Advanced Java
    Replies: 0
    Last Post: 03-20-2009, 09:48 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •