eclipse用jdbc连接mysql数据库时,url是填什么?怎样找出地址?

eclipse用jdbc连接mysql数据库时,url是填什么?怎样找出地址?,第1张

1、首先登陆mysql,查看mysql的数据情况,select * from test_data1 t

2、新建java类,测试jdbc功能

3、编写java的jdbc代码

String driver = "com.mysql.cj.jdbc.Driver"

String url = "jdbc:mysql://localhost:3306/testdb?characterEncoding=utf8&useSSL=false"

String user = "root"

String pwd = "123456"

4、代码中查询mysql数据表,并执行查出表中内容;select * from test_data1

你的密码是"",你确定没错,你安装mysql的时候密码是不可能为空的,一定有密码的。

但是你的Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "")密码是空字符串,肯定是不可能的。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6110943.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存