JDBC going to the wrong address

Posted by DCSoft on Stack Overflow See other posts from Stack Overflow or by DCSoft
Published on 2012-06-06T22:37:10Z Indexed on 2012/06/06 22:40 UTC
Read the original article Hit count: 187

Filed under:

When I try and connect it my mysql database with JDBC in java, it doesn't go to my web server.

Here is the code

String dbtime;
String dbUrl = "jdbc:mysql://184.172.176.18:3306/dcsoft_dcsoft_balloon";
String dbUser = "myuser";
String dcPass = "mypass";
String dbClass = "com.mysql.jdbc.Driver";
String query = "Select * FROM users";

try {

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(dbUrl, dbUser, dcPass);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} //end while
con.close();
} //end try
catch(ClassNotFoundException e) {
e.printStackTrace();
}
catch(SQLException e) {
e.printStackTrace();
}

This code is supposed to go to my web server but it gives this error java.sql.SQLException: Access denied for user 'dcsoft_dcsoft_java'@'jamesposse.force9.co.uk' (using password: YES)

jamesposse.force9.co.uk is the not the address im trying to connect to I'm trying to connect to 184.172.176.18:3306.

Thanks.

© Stack Overflow or respective owner

Related posts about java