当前位置:网站首页>JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
2022-04-23 02:00:00 【CSDN Q & A】
import small_program.linksql.Student;import small_program.linksql.utils.JDBCUtils;import java.sql.*;import java.util.ArrayList;public class StudentDaoimpl implements StudentDao { @Override public ArrayList<Student> findAll() { ArrayList<Student> students = new ArrayList<>(); Connection connection = null; Statement statement = null; ResultSet rs = null; try { Class.forName("com.mysql.cj.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://10.200.36.189:3306/db14","root","123456"); // register , Connect // Get execution object // connection = JDBCUtils.getConnection(); statement = connection.createStatement(); // perform SQL And receive the returned result set String sql = "select * from student"; rs = statement.executeQuery(sql); // Processing results while (rs.next()) { Integer sid = rs.getInt("sid"); String name = rs.getString("name"); Integer age = rs.getInt("age"); Date date = rs.getDate("date"); Student student = new Student(sid, name, age, date); students.add(student); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(rs,statement,connection); } return students; } @Override public Student findById(Integer id) { Student student1 = new Student(); Connection connection = null; Statement statement = null; ResultSet rs = null; try { // register , Connect // Get execution object Class.forName("com.mysql.cj.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://10.200.36.189:3306/db14","root","123456");// connection = JDBCUtils.getConnection(); statement = connection.createStatement(); // perform SQL And receive the returned result set String sql = "select * from student where sid = id"; rs = statement.executeQuery(sql); // Processing results while (rs.next()) { Integer sid = rs.getInt("sid"); String name = rs.getString("name"); Integer age = rs.getInt("age"); Date date = rs.getDate("date"); student1.setSid(sid); student1.setName(name); student1.setAge(age); student1.setBirthday(date); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtils.close(statement,connection); return student1; } } @Override public int insert(Student student) { return 0; } @Override public int update(Student student) { return 0; } @Override public int del(Integer id) { return 0; }}
Take the answer :
It's not a password problem
版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211146414891.html
边栏推荐
- Error in face detection and signature of Tencent cloud interface
- Do447 manage user and team access
- Analyze the three functions of static proxy IP.
- [经验教程]支付宝余额自动转入余额宝怎么设置关闭取消支付宝余额自动转入余额宝?
- 什么是api接口?
- J-Link RTT使用
- 领导/老师让填写电子excel表格文档可手机上如何编辑word/excel文件填写excel/word电子文档?
- EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
- 2022.4.20-----leetcode.388
- App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
猜你喜欢

拨号服务器是什么,有什么用处?
![[experience tutorial] Alipay balance automatically transferred to the balance of treasure how to set off, cancel Alipay balance automatically transferred to balance treasure?](/img/d5/6aa14af59144b8c99aa6a367479f6b.png)
[experience tutorial] Alipay balance automatically transferred to the balance of treasure how to set off, cancel Alipay balance automatically transferred to balance treasure?

Challenges often faced by client project management

一些使用代理IP的小技巧。

腾讯云接口进行人脸检测 和签名出错问题

力扣(LeetCode)112. 路径总和(2022.04.22)

批处理多个文件合成一个HEX

W801 / w800 WiFi socket development (II) - UDP Bluetooth control WiFi connection

Is the availability of proxy IP equal to the efficiency of proxy IP?

什么是代理IP池,如何构建?
随机推荐
教程】如何用GCC“零汇编”白嫖MDK
. net unit test Part 1: common Net unit test framework?
校园转转二手市场源码
What are the common proxy IP problems?
PID精讲
浅析静态代理ip的三大作用。
W801 / w800 WiFi socket development (I) - UDP
紫光国微财报一枝独秀 2021年净利润三位数增长靠什么
Micro build low code zero foundation introductory course
Introduction to micro build low code zero Foundation (lesson 2)
Question bank and online simulation examination for safety management personnel of hazardous chemical business units in 2022
2022.4.10-----leetcode.804
What business scenarios will the BGP server be used in?
K zeros after leetcode factorial function
最长公共子序列(记录路径版)
Use of j-link RTT
Error in face detection and signature of Tencent cloud interface
What businesses use physical servers?
搭建网站是用物理机还是云主机好?
What are the benefits of writing unit tests using the unit test framework?