關于jdbc.properties文件中的書寫格式問題會造成數據的讀寫的失敗問題
老師,是這樣的:
如果我是這樣子寫的
driver = com.mysql.jdbc.Driver
url = jdbc:mysql://127.0.0.1:3306/secondkill?useUnicode=true&characterEncoding=utf8
username = root
password = root
然后程序就會報錯
### Error querying database. ?Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
### The error may exist in file [D:\Program\P_IntelliJ_IDEA_Project\secondKil03\target\classes\mapper\SeckillDao.xml]
### The error may involve org.secondKill.dao.SeckillDao.queryById
### The error occurred while executing a query
但是如果我將jdbc.properties的內容修改為:
jdbc.driver = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://127.0.0.1:3306/secondkill?useUnicode=true&characterEncoding=utf8
jdbc.username = root
jdbc.password = root
然后在spring-dao中對dataSource的配置作出相同的修改,那么程序就可以正常執行了。
Spring版本4.2.5 Release版本
這個問題的原因我應該從哪一方面去入手解決呢?
謝謝老師
2016-06-11
可能是jvm環境變量里有username參數導致替換了。
2016-05-30
我也遇到了,username改個名字就好,比如改成user。但是我的spring版本和老師的一樣,換了版本也不行,不知道哪里有問題,連接池用BasicDataSource也不行。