老問題,數(shù)據(jù)庫連接不上,求解決!??!
嘗試了所有評論中的方法,依然連接不上?。?!
1.修改jdbc.properties
jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=uft8&serverTimezone=UTC&useSSL=false jdbc.user=root jdbc.password=***
同時修改spring-dao.xml;另將超時時間改為0,無限等待
<bean?id="dataSource"?class="com.mchange.v2.c3p0.ComboPooledDataSource"> ????<property?name="driverClass"?value="${jdbc.driver}"/> ????<property?name="jdbcUrl"?value="${jdbc.url}"/> ????<property?name="user"?value="${jdbc.user}"/> ????<property?name="password"?value="${jdbc.password}"/> ????<!--?c3p0連接池的私有屬性?--> ????<!--?數(shù)據(jù)庫最大連接對象?默認:15?--> ????<property?name="maxPoolSize"?value="30"/> ????<!--?數(shù)據(jù)庫最小連接對象?默認:3?--> ????<property?name="minPoolSize"?value="10"/> ????<!--?關(guān)閉連接后不自動commit?默認:false?--> ????<property?name="autoCommitOnClose"?value="false"/> ????<!--?獲取連接超時時間?默認:0,表示無限等待--> ????<property?name="checkoutTimeout"?value="0"/> ????<!--?當獲取連接失敗時重試次數(shù)?--> ????<property?name="acquireRetryAttempts"?value="2"/> </bean>
3.修改pom.xml中各項配置版本
<dependency> ??<groupId>mysql</groupId> ??<artifactId>mysql-connector-java</artifactId> ??<version>8.0.11</version> ??<scope>runtime</scope> </dependency> <dependency> ??<groupId>com.mchange</groupId> ??<artifactId>c3p0</artifactId> ??<version>0.9.5.2</version> </dependency>
依然報錯
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:?
### Error querying database.? Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
### The error may exist in file [F:\seckill\target\classes\mapper\SeckillDao.xml]
### The error may involve org.seckill.dao.SeckillDao.queryById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
已經(jīng)無力了,求大神解決!?。?/p>
2021-02-25
utf你打成了uft