Jump to content

[Solved] Connecting to Database?


lauraccc

Recommended Posts

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?

 

Link to comment
Share on other sites

 

("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.

Link to comment
Share on other sites

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 (…...

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

'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.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...