lauraccc Posted February 19, 2019 Posted February 19, 2019 Hi for my website I need to connect to a database. I have a MySQL database created and is on myphpadmin. In my code for my jsp I am using a connection string, Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lauraccc_fyp", "root", "*");, however when I try to run this jsp page on heliohost it is not connecting and I am getting a blank page. I am doing something wrong?
wolstech Posted February 19, 2019 Posted February 19, 2019 ("jdbc:mysql://localhost:3306/lauraccc_fyp", "root", "*"); You need to create a database user in cPanel, assign it to the DB, then specify that username and password in the connection string. Users don't have root access here unlike on a development box.
lauraccc Posted February 19, 2019 Author Posted February 19, 2019 I am still receiving a blank jsp page. My database is called lauraccc_fyp, my username is lauraccc_root and I have the correct passowrd. I am trying to insert into a table called lauraccc_fyp.register and the status is ok in cPanel Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lauraccc_fyp", "lauraccc_root", "****"); Statement stmt = con.createStatement(); stmt.execute("insert into lauraccc_fyp.register (…...
wolstech Posted February 19, 2019 Posted February 19, 2019 Krydos knows more about Java than most of us. Lets see if he knows why this doesn't work... 1
Krydos Posted February 19, 2019 Posted February 19, 2019 When uploading .jsp files, etc. to your public_html folder the .jar files aren't loaded until Tomcat restarts. So likely what is happening is your site just doesn't have its mysql-connector loaded. I have restarted Tomcat. Are your mysql connections working now?
lauraccc Posted February 26, 2019 Author Posted February 26, 2019 Hi no my connections are still not working. Do I need to have uploaded a mySQL connector to cPanel as well?
lauraccc Posted February 26, 2019 Author Posted February 26, 2019 I am recieving; java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) error if that gives any indication?
Krydos Posted February 27, 2019 Posted February 27, 2019 'root'@'localhost'You don't have the root password for the server for obvious security reasons. Your mysql username will be something like lauraccc_root. You can create databases and database users through the mysql button in cpanel.
lauraccc Posted February 28, 2019 Author Posted February 28, 2019 Sorry for still bothering but I am still receiving this error. mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'lauraccc_root'@'localhost' to database 'lauraccc_fyp'
lauraccc Posted February 28, 2019 Author Posted February 28, 2019 I have it working now, thank you for all your help. I will be donating
Recommended Posts