com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class b

编写服务器程序,编写完成后,服务器能够正常启动,但是访问数据库时,报com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "mysql:"'.错误。Cannot load connection class because of underlying exception,因为加载不到连接。

但单元测试能够正常访问数据库,猜测原因为WEB访问数据库时,数据库连接未建立导致,尝试使用静态代码块加载连接,使其在服务器一开始的时候加载连接。问题得以解决。

上一篇:InvalidOperationException: Cannot create a DbSet for 'IdentityUserClaim' bec


下一篇:Job for docker.service failed because start of the service was attempted too often