为了账号安全,请及时绑定邮箱和手机立即绑定

一直提示连接不到数据库,pom文件中引入了数据库连接

java.sql.SQLException: com.mysql.jdbc.Driver

at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:570)

at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:697)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1069)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1065)

at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:104)

at org.apache.shiro.realm.jdbc.JdbcRealm.doGetAuthenticationInfo(JdbcRealm.java:215)

at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:568)

at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180)

at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267)

at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)

at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)

at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:270)

at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:256)

at com.imooc.test.JdbcRealmTest.testAuthentication(JdbcRealmTest.java:30)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


正在回答

1 回答

datasource.setUrl("jdbc:mysql://localhost:3306/test");
datasource.setUsername("root");
datasource.setPassword("1234");

加一个驱动注册就行了
datasource.setDriverClassName("com.mysql.jdbc.Driver");

然后建一个表就行了

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

一直提示连接不到数据库,pom文件中引入了数据库连接

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信