Hello,I am trying to set the connection for MySQL in the script: So far it is throwing me an errorBelow is the code. Can you please help me where I am doing mistake. For url and Pwd, I am giving credentials, but didn’t mention here
String dbUrl ="avcmg-di.cua8asf8jbhp.us-west-2.rds.amazonaws.com :3306";
String username = "avcmg_user";
String password = "directv1" ;
Connection con = DriverManager.getConnection("dbUrl","username", "password");
String query ="select guide_ccid from av_channels";
ResultSet rs= stmt.executeQuery(query);
Could you please show us the error details?But by checking your script, I think that the value for dbUrl should be follow the style below:jdbc:mysql://[DBHOST]:[DBPORT]/[DBNAME]
Then maybeString dbUrl ="jdbc:mysql://avcmg-di.cua8asf8jbhp.us-west-2.rds.amazonaws.com:3306/[DBNAME]";And I could not find [DBNAME] information in your script. Then you need to replace real your MySQL Database name in this part [DBNAME].
I believe the issue is with the following line in your code:
You have mistakenly passed in the literal string values, "dbUrl", "username", "password", instead of passing in the String variables: dbUrl, username, password. In other words change it to the following (notice I have removed the quotation marks ("")):
Connection con = DriverManager.getConnection(dbUrl, username, password);
From your code, problem is in dbUrl string which you have mentioned. Since you are using mysql JDBC driver, connection string should be in format as jdbc:mysql://[DBHOST]:[DBPORT]/[DBNAME]
Please change the connection string to above format and test it.
Thanks & Regards