0

so I know this has been asked alot and I havelooked on here to find the answer but I have a have a ddns through no IP and I am trying to access my database through Java my code is as follows

package POJOS;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DBConnection 
{
   private Connection connection;
   private Statement statement;
   private ResultSet resultSet;

    public DBConnection() 
    {
        connectToDB();
    }
    private void connectToDB()
    {
        String 
                driver = "com.mysql.jdbc.Driver",
                url = "jdbc:mysql://clubdatabase.ddns.net:8080/programming_club",
                userName = "root",
                password = "";
       try 
       {
           Class.forName(driver); 
           connection = (Connection) DriverManager.getConnection(url,userName,password);
           System.out.println("Connection to server successful!");
       }
       catch (ClassNotFoundException ex) 
       {
           Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
       } catch (SQLException ex) {
           Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
       }
    }
    public static void main(String[] args) {
        DBConnection dBConnection = new DBConnection();
    }
}

so if you type in the address in the url it will bring you to my server I even tried to put /phpmyadmin/programming_club but it still doesnt work. does anyone have any idea why ?

Bobby Gannard
  • 65
  • 1
  • 8

0 Answers0