网站搭建高防服务器租用企业高防服务器mybatis链接数据库出错
-
≥ 1台¥600.00
网站搭建高防服务器租用 企业高防服务器mybatis链接数据库出错
高防服务器租用 请联系:锐辉网络--小敏 :.........................................2853898501
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error getting a new connection. Cause: java.sql.SQLException: No suitable driver found for jdbc\:mysql\://192.168.100.251\:3306/wbj_bus?useUnicode\=true&characterEncoding\=UTF-8
### Cause: java.sql.SQLException: No suitable driver found for jdbc\:mysql\://192.168.100.251\:3306/wbj_bus?useUnicode\=true&characterEncoding\=UTF-8
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getConnection(DefaultSqlSession.java:222)
at cn.itcast.javaee.mybatis.util.MybatisUtil.main(MybatisUtil.java:75)
Caused by: java.sql.SQLException: No suitable driver found for jdbc\:mysql\://192.168.100.251\:3306/wbj_bus?useUnicode\=true&characterEncoding\=UTF-8
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
atorg.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:181)
atorg.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:176)
atorg.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:80)
atorg.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:371
at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:80)
at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:131)
at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:58)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getConnection(DefaultSqlSession.java:220)
... 1 more
一开始认为是驱动出的错(数据库驱动不对),不过显然不是。
后来将jdbc.url=jdbc\:mysql\://192.168.100.251\:3306/wbj_bus?useUnicode\=true&characterEncoding\=UTF-8中的转义字符去掉,变成:
<property name="url" value="jdbc:mysql://192.168.100.251:3306/wbj_bus?useUnicode=true&characterEncoding=UTF-8"/>
再次执行就连接成功!
log4j:WARN See #noconfig for more info.
连接成功