If I have a mysql database on my own pc, I would use the foll开发者_如何学Goowing cnxn string to connect it to my java program :
String url = "jdbc:mysql://localhost:port/dbname";
But if my database is made over phpMyAdmin, what would be the connection string ? one other note, the phpmyadmin database is not on my local pc now, it is on another one but both pc are in the same network.
Thanks for any help ..
phpMyadmin is administration web application developed on PHP platform. phpMyadmin connects to MySQL database that might be on other machine.
you need to check config.inc.php file of phpMyadmin to check the host and port of mysql database.
Once you get the IP and port of the mysql database you can connect using connect string like
jdbc:mysql://<ipaddress>:<port>/<database_created_through_phpMyAdmin>
Replace localhost with the IP of the machine that hosts your database:
String url = "jdbc:mysql://<ip_goes_here>:port/dbname";
As Rutesh mentions, this may or may not be the same machine on which phpMyAdmin runs.
精彩评论