org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQ

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc.mysql://localhost:3309/test
### The error may exist in mapper/User.xml
### The error may involve com.findById
### The error occurred while executing a query
### Cause: java.sql.SQLException: No suitable driver found for jdbc.mysql://localhost:3309/test
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:73)
    at test.main(test.java:22)
Caused by: java.sql.SQLException: No suitable driver found for jdbc.mysql://localhost:3309/test
    at java.sql.DriverManager.getConnection(DriverManager.java:689)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:140)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:62)
    at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:315)
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:75)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:61)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
    ... 3 more
 

报错,我在网上试了两个关于mybatis的代码,都有出现这样的错误,明明代码一样,但是偏偏出差,最后的解决方法就是

改成

即value的值由jdbc.mysql://localhost:3309/test  改成jdbc:mysql://localhost:3309/test

(3309是我数据库的端口号,查找自己的数据库端口号语句是:show global variables like 'port';)

(test是我的数据库名称)

最后结果:

org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQ_第1张图片

 

你可能感兴趣的:(org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQ)