Port number for JDBC connection to database in MySQL
JDBC连接数据库时我是使用的纯java驱动方式(驱动可从MySQL官网上下载,网址为http://dev.mysql.com/downloads/connector/j/,解压后其实只需要其中的mysql-connector-java-5.1.xxx-bin.jar这一个文件,其它干哈的我也不清楚),其中在连接数据库时老是提示代码有错误:
String url=”jdbc:mysql://localhost:8080/workdb”;
Connection con=DriverManager.getConnection(url,”root”,”278845421″);
原因是端口号错了,我还是用的tomcat的端口号,这次应该是用MySQL的端口号,但并不值得MySQL的端口号是多少,只是从网上查是这样的
mysql的默认端口是3306,可以编辑用户目录下的 .my.cnf 文件进行修改。
sqlserver默认端口号为:1433
oracle 默认端口号为:1521
DB2 默认端口号为:5000
PostgreSQL默认端口号为:5432
于是我把端口号3306替换上果然成功了,但还是不知道这个3306是从哪来的,于是我打开
输入密码登录
输入指令show global variables like ‘port’;查看端口号
port果然是3306,所以就可以大胆的用了,如果想修改端口号,就必须打开文件进行修改
912sy.com download resources are from the network, only for learning and reference use, the copyright belongs to the original author, do not use for commercial purposes, please remove yourself within 24 hours after downloading.
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " Port number for JDBC connection to database in MySQL
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " Port number for JDBC connection to database in MySQL