2 weixin 35865171 weixin_35865171 于 2016.09.11 14:57 提问

请问这个是不是JDBC驱动没配置好。还是JDBC与mysql 的版本不对应?大神求救啊

java.sql.SQLException: No suitable driver found for jdbc:mysql:localhost:3306/test
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:208)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.DatabaseExporter.(DatabaseExporter.java:52)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:367)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:304)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:293)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:500)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1790)
at StudentsTest.init(StudentsTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

5个回答

yechaoa
yechaoa   2016.09.11 15:22

没配置好吧,地址再检查检查,账号密码什么的

weixin_35865171
weixin_35865171 嗯谢谢了,我以为是JDBC要和mysql版本对应呢
一年多之前 回复
dj159357
dj159357   2016.09.11 16:11

驱动没有配置好,看你的第一句话,就说啦,没有适当的驱动。。。。。对啦,你代码中把驱动注册啦吗?class.forName("com.mysql.jdbc.Driver")

weixin_35865171
weixin_35865171 注册了,谢谢了 我去检查下配置。
一年多之前 回复
GOODLUCKYGO
GOODLUCKYGO   2016.09.11 16:37

驱动没有装好,重新装一个驱动,就可以了
java.sql.SQLException: No suitable driver found for jdbc:mysql:localhost:3306/test
说明驱动的原因。然后看下数据库的名字是否写错了。

u013829202
u013829202   Rxr 2016.09.11 20:42

localhost前面差两斜杠。应该是: jdbc:mysql://localhost:3306/test

sunrise_zhu
sunrise_zhu   2016.09.11 21:18

你是url写错了,
url应该写成:jdbc:mysql://localhost:3306/test

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!