0

我是新手,我做了 helloWorld 教程,顺便说一句,非常令人印象深刻,但我现在正试图连接到一个真正的 postgres 数据库,当我觉得它应该很简单时,我发现自己正在努力让驱动程序被识别。

我将所有用于 postgres 的 jdbc 驱动程序放到了 persevere/lib 文件夹中:

  • postgresql-8.3-603.jdbc2ee.jar
  • postgresql-8.3-603.jdbc2.jar
  • postgresql-8.3-603.jdbc3.jar
  • postgresql-8.3-603.jdbc4.jar

然而,当我开始坚持使用命令“persvr”时,我的项目文件夹中没有任何参数,我收到以下错误消息:

java.lang.ClassNotFoundException: org.postgresql.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:379)
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:341)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.persvr.datasource.DatabaseDataSource.initParameters(Unknown Source)
    at org.persvr.datasource.DatabaseTableDataSource.initParameters(Unknown Source)
    at org.persvr.data.DataSourceManager.initSource(Unknown Source)
    at org.persvr.data.DataSourceManager.<clinit>(Unknown Source)
    at org.persvr.data.Identification.idForString(Unknown Source)
    at org.persvr.Persevere.load(Unknown Source)
    at org.persvr.job.SampleData.execute(Unknown Source)
    at org.persvr.job.Upgrade.execute(Unknown Source)
    at org.persvr.remote.PersevereFilter.init(Unknown Source)
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:620)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1234)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:460)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.persvr.util.JettyStart.main(Unknown Source)

我实际上是在尝试将 helloWorld 项目扩展为一个练习,所以我在我的 helloWorld/WEB-INF/config 文件夹中添加了一个 postgres.json 文件。这是该文件的内容:

    {"id":"postgres.json",
"sources":[
        {"name":"addressTable",
                "sourceClass":"org.persvr.datasource.DatabaseTableDataSource",
                "connection":"jdbc:postgresql://hostname:5432/pnp?user=user1&pass=mypassword",
                "driver":"org.postgresql.Driver",
                "camelCaseColumnNames": false,
                "table":"addr",
                "idColumn":"addr_id",
                "dataColumns":["addr_stat_cd","addr1","addr2","city","state","zip","zip_ext","cntry_cd","last_upd_uid","last_upd_dttm","create_uid","create_dt
tm"],
        "schema":{
                "data":{"$ref":"../addressTable/"}
        }
}]
}

谁能告诉我为什么坚持找不到那个postgres驱动程序?

谢谢,兰斯洛特。

4

1 回答 1

0

弄清楚了。postgres 驱动程序 jar 实际上应该进入文件夹:persevere/WEB-INF/lib 而不是 persevere/lib。

于 2009-04-09T17:46:58.220 回答