【⭐】Java—Spring-—数据库操作—使用内置连接池,报读取不到驱动错误。Could not load JDBC driver class。
程序员文章站
2023-01-01 10:03:38
项目功能: 连接MySql数据库,向数据库插入一条数据 项目结构: DEBUG信息: juint信息: 分析: 1.配置文件出错。 (1)检测jdbc.properties————————————没有错误 (2)检测applicationContext.xml————————没有错误 2.JAR包错 ......
项目功能:
连接mysql数据库,向数据库插入一条数据
项目结构:
debug信息:
debug [main] - destroying singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@67b92f0a: defining beans
[org.springframework.context.support.propertysourcesplaceholderconfigurer#0,studentservice,studentdao,datasource]; root of factory hierarchy
juint信息:
org.springframework.beans.factory.beancreationexception:
error creating bean with name 'studentservice' defined in class path resource [applicationcontext.xml]:
cannot resolve reference to bean 'studentdao' while setting bean property 'studentdao';
nested exception is org.springframework.beans.factory.beancreationexception:
error creating bean with name 'studentdao' defined in class path resource [applicationcontext.xml]:
cannot resolve reference to bean 'datasource' while setting bean property 'datasource';
nested exception is org.springframework.beans.factory.beancreationexception:
error creating bean with name 'datasource' defined in class path resource [applicationcontext.xml]:
error setting property values; nested exception is org.springframework.beans.propertybatchupdateexception;
nested propertyaccessexceptions (1) are:
propertyaccessexception 1: org.springframework.beans.methodinvocationexception:
property 'driverclassname' threw exception; nested exception is java.lang.illegalstateexception: could not load jdbc driver class [${jdbc.driverclass]
分析:
1.配置文件出错。
(1)检测jdbc.properties————————————没有错误
(2)检测applicationcontext.xml————————没有错误
2.jar包错误
(1)重新导包————————————————解决错误,成功连接数据库,插入数据。
问题原因:
产生错误时使用的jar包: 重新导入的jar包:
缺少mysql-connector-java-5.1.13-bin.jar包!!
所以报的是无法找到驱动。