mysql jdbc驱动程序NumberFormatException

时间:2015-12-21 18:50:18

标签: mysql scala jdbc playframework slick

我正在尝试使用clearDB部署我在Heroku使用play(scala)+ play-slick的app,我收到以下错误:

2015-12-18T22:31:12.042179+00:00 app[web.1]: java.sql.SQLTimeoutException: Timeout after 1000ms of waiting for a connection.
2015-12-18T22:31:12.042430+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:227)
2015-12-18T22:31:12.042512+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:182)
2015-12-18T22:31:12.042589+00:00 app[web.1]:    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:93)
2015-12-18T22:31:12.042666+00:00 app[web.1]:    at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:12)
2015-12-18T22:31:12.042743+00:00 app[web.1]:    at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:56)
2015-12-18T22:31:12.042854+00:00 app[web.1]:    at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:59)
2015-12-18T22:31:12.042930+00:00 app[web.1]:    at play.api.db.evolutions.DatabaseEvolutions.databaseEvolutions(EvolutionsApi.scala:119)
2015-12-18T22:31:12.043000+00:00 app[web.1]:    at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:97)
2015-12-18T22:31:12.043071+00:00 app[web.1]:    at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:112)
2015-12-18T22:31:12.043825+00:00 app[web.1]:    at play.api.db.evolutions.DefaultEvolutionsApi.scripts(EvolutionsApi.scala:77)
2015-12-18T22:31:12.043946+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions$$anonfun$play$api$db$evolutions$ApplicationEvolutions$$runEvolutions$1.apply$mcV$sp(ApplicationEvolutions.scala:50)
2015-12-18T22:31:12.044049+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions.withLock(ApplicationEvolutions.scala:98)
2015-12-18T22:31:12.044123+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions.play$api$db$evolutions$ApplicationEvolutions$$runEvolutions(ApplicationEvolutions.scala:49)
2015-12-18T22:31:12.044241+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start$1.apply(ApplicationEvolutions.scala:42)
2015-12-18T22:31:12.044318+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start$1.apply(ApplicationEvolutions.scala:42)
2015-12-18T22:31:12.044416+00:00 app[web.1]:    at scala.collection.immutable.Stream.foreach(Stream.scala:594)
2015-12-18T22:31:12.044487+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:42)
2015-12-18T22:31:12.044623+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:149)
2015-12-18T22:31:12.044721+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:53)
2015-12-18T22:31:12.044797+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:53)
2015-12-18T22:31:12.044902+00:00 app[web.1]:    at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:44)
2015-12-18T22:31:12.044976+00:00 app[web.1]:    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
2015-12-18T22:31:12.045122+00:00 app[web.1]:    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
2015-12-18T22:31:12.045230+00:00 app[web.1]:    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
2015-12-18T22:31:12.045325+00:00 app[web.1]:    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
2015-12-18T22:31:12.045430+00:00 app[web.1]:    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
2015-12-18T22:31:12.045559+00:00 app[web.1]:    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
2015-12-18T22:31:12.045636+00:00 app[web.1]:    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
2015-12-18T22:31:12.045733+00:00 app[web.1]:    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
2015-12-18T22:31:12.045816+00:00 app[web.1]:    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
2015-12-18T22:31:12.046389+00:00 app[web.1]:    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
2015-12-18T22:31:12.046492+00:00 app[web.1]:    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
2015-12-18T22:31:12.046569+00:00 app[web.1]:    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
2015-12-18T22:31:12.046655+00:00 app[web.1]:    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
2015-12-18T22:31:12.046703+00:00 app[web.1]:    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
2015-12-18T22:31:12.046754+00:00 app[web.1]:    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
2015-12-18T22:31:12.046799+00:00 app[web.1]:    at com.google.inject.Guice.createInjector(Guice.java:96)
2015-12-18T22:31:12.046854+00:00 app[web.1]:    at com.google.inject.Guice.createInjector(Guice.java:73)
2015-12-18T22:31:12.046917+00:00 app[web.1]:    at com.google.inject.Guice.createInjector(Guice.java:62)
2015-12-18T22:31:12.046949+00:00 app[web.1]:    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
2015-12-18T22:31:12.047006+00:00 app[web.1]:    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
2015-12-18T22:31:12.047056+00:00 app[web.1]:    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
2015-12-18T22:31:12.047155+00:00 app[web.1]:    at play.core.server.ProdServerStart$.start(ProdServerStart.scala:52)
2015-12-18T22:31:12.047233+00:00 app[web.1]:    at play.core.server.ProdServerStart$.main(ProdServerStart.scala:27)
2015-12-18T22:31:12.047303+00:00 app[web.1]:    at play.core.server.ProdServerStart.main(ProdServerStart.scala)
2015-12-18T22:31:12.047760+00:00 app[web.1]: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "8535df66@eu-cdbr-west-01.cleardb.com"'.
2015-12-18T22:31:12.047838+00:00 app[web.1]:    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2015-12-18T22:31:12.047913+00:00 app[web.1]:    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2015-12-18T22:31:12.047988+00:00 app[web.1]:    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2015-12-18T22:31:12.048085+00:00 app[web.1]:    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
2015-12-18T22:31:12.048161+00:00 app[web.1]:    at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
2015-12-18T22:31:12.048230+00:00 app[web.1]:    at com.mysql.jdbc.Util.getInstance(Util.java:360)
2015-12-18T22:31:12.048300+00:00 app[web.1]:    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
2015-12-18T22:31:12.048372+00:00 app[web.1]:    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
2015-12-18T22:31:12.048441+00:00 app[web.1]:    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
2015-12-18T22:31:12.048554+00:00 app[web.1]:    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
2015-12-18T22:31:12.048623+00:00 app[web.1]:    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:333)
2015-12-18T22:31:12.048706+00:00 app[web.1]:    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:92)
2015-12-18T22:31:12.048779+00:00 app[web.1]:    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:98)
2015-12-18T22:31:12.048851+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHikariPool.addConnection(BaseHikariPool.java:438)
2015-12-18T22:31:12.048927+00:00 app[web.1]:    at com.zaxxer.hikari.pool.BaseHikariPool$1.run(BaseHikariPool.java:413)
2015-12-18T22:31:12.049058+00:00 app[web.1]:    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
2015-12-18T22:31:12.049135+00:00 app[web.1]:    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2015-12-18T22:31:12.049207+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2015-12-18T22:31:12.049280+00:00 app[web.1]:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2015-12-18T22:31:12.049352+00:00 app[web.1]:    at java.lang.Thread.run(Thread.java:745)
2015-12-18T22:31:12.049667+00:00 app[web.1]: Caused by: java.lang.NumberFormatException: For input string: "8535df66@eu-cdbr-west-01.cleardb.com"
2015-12-18T22:31:12.049742+00:00 app[web.1]:    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
2015-12-18T22:31:12.049816+00:00 app[web.1]:    at java.lang.Integer.parseInt(Integer.java:580)
2015-12-18T22:31:12.049887+00:00 app[web.1]:    at java.lang.Integer.parseInt(Integer.java:615)
2015-12-18T22:31:12.049965+00:00 app[web.1]:    at com.mysql.jdbc.NonRegisteringDriver.port(NonRegisteringDriver.java:822)
2015-12-18T22:31:12.050039+00:00 app[web.1]:    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
2015-12-18T22:31:12.050120+00:00 app[web.1]:    ... 9 more
2015-12-18T22:31:12.905287+00:00 heroku[web.1]: Process exited with status 255

the database url is something like (info [here](https://devcenter.heroku.com/articles/cleardb#configuring-your-ruby-application-to-use-cleardb)) and it's from clearDB:


slick.dbs.default.db.url = "jdbc:mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true"

据我看到同样的问题happened long time ago,玩游戏1。

我正在使用play 2.4.4和play-slick 1.1.0。是重新引入的错误吗?或者我错过了什么?它是一个mysql驱动程序(已知)问题吗?

3 个答案:

答案 0 :(得分:2)

play-framework mailing list

上的解决方案

排序答案:

  

&#34;看起来mysql jdbc驱动程序无法解析输入字符串&#34; 8535 ... @ eu-cdbr-west-01.cleardb.com“,这似乎没有来自Play或Play-slick&#34;

最终解决方案:

slick.dbs.default.driver = "slick.driver.MySQLDriver$"
slick.dbs.default.db.driver = "com.mysql.jdbc.Driver"
slick.dbs.default.db.url = "jdbc:mysql://eu-cdbr-west-01.cleardb.com/DATABASE"
slick.dbs.default.db.user = "USER"
slick.dbs.default.db.password = "PASS"
slick.dbs.default.db.connectionTimeout = 10 seconds

我知道10秒钟,它只是为了测试。

答案 1 :(得分:1)

MySQL驱动程序将adffdadf2341:adf4234@us-cdbr-east.cleardb.com视为host:port,因此它将adf4234@us-cdbr-east.cleardb.com视为端口号,并尝试将其转换为整数。

如果这些是使用默认端口号的多个主机,请替换&#39;:&#39;与&#39;,&#39;。

答案 2 :(得分:0)

我认为问题在于你的框架无法吞噬整个mysql网址。您需要将其解析为其组件(用户名,密码,主机名,数据库名称),并将它们填入适当的字段。