2

Scala 2.10 とSlick 2.10-1.0.1 を単純なクエリで使用しています。

Tomcat at で遅延評価データベースを初期化しようとしましたlocalhost。クエリの評価には、ポートで PostgreSQL を使用します5432

コンパイルしようとすると、次のエラーメッセージが表示されました。

ERROR org.quartz.core.JobRunShell - Job DEFAULT.MissionLifecycleManager threw an unhandled Exception: org.postgresql.util.PSQLException: ERROR: improper qualified name (too many dotted names)
  Position: 16
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) ~[postgresql-9.1-901.jdbc4.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381) ~[postgresql-9.1-901.jdbc4.jar:na]
at scala.slick.jdbc.StatementInvoker.results(StatementInvoker.scala:34) ~[slick_2.10-1.0.1.jar:1.0.1]
at scala.slick.jdbc.StatementInvoker.elementsTo(StatementInvoker.scala:17) ~[slick_2.10-1.0.1.jar:1.0.1]
....

これは私の初期化のコードです:

import com.weiglewilczek.slf4s.Logging
import scala.slick.driver.PostgresDriver._
import scala.slick.session.Database
import Database.threadLocalSession
import scala.slick.jdbc.{GetResult, StaticQuery => Q}
import scala.slick.driver.PostgresDriver.simple._

object SQLUtilities extends Logging with ServiceInjector {
    lazy val db = init()

    private def init() = {
        info("Connecting to postgres database at localhost") //writes in a log file

        val qe = Database.forURL("jdbc:postgresql://localhost:5432", "user", "pass", driver = "org.postgresql.Driver")
        info("Connected to database")
        qe
    }
}

明らかに、何かがうまくいかなかった。だから、データベースの初期化が正しくないと思います。いくつかのパラメータを忘れましたか? 私のパラメータはまったく正しいですか?

別の-それほど致命的ではない-質問:メソッドの最初と最後に何かをログに記録したい本体がある場合-常に同じログメッセージとしましょうが、本体は異なります-私が開始した兆候としてこのメソッドを残しました...ここにあるこの例よりもこれを行う適切な方法はありinit()ますか?

4

1 に答える 1

3

接続文字列「jdbc:postgresql://localhost:5432/somedatabase」でデータベースを指定します。

http://jdbc.postgresql.org/documentation/head/connect.htmlを参照してください。

于 2013-11-14T13:32:25.823 に答える