Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.

报错代码

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Exception in thread "main" java.sql.SQLSyntaxErrorException: Table 'jdbcstudy.user' doesn't exist
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1200)
	at org.example.FistDemo.main(FistDemo.java:21)

报错原因

编写SQL语句的时候,查询的数据库对应的表名称写错了,代码找不到对应的表,写成user了

改错方法

将数据库名称改成你数据库对应的表的名称

修改后的运行截图

posted @ 2023-05-15 11:12  YE-  阅读(32)  评论(0编辑  收藏  举报