坚持数据源驱动程序

发布于 2024-07-16 15:09:19 字数 3830 浏览 5 评论 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 项目扩展为练习,因此我添加了一个 postgres .json 文件位于我的 helloWorld/WEB-INF/config 文件夹中。 以下是该文件的内容:

    {"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/"}
        }
}]
}

谁能告诉我为什么 persevere 找不到 postgres 驱动程序?

谢谢, 兰斯洛特。

I'm new to persevere, I did the helloWorld tutorial, very impressive btw but I'm now trying to connect to a real postgres database and find myself struggling having the driver recognized when I have the feeling it should be dead simple.

I dropped all the jdbc driver for postgres I had to the persevere/lib folder:

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

And yet when I start persevere with the command "persvr" with no argument from my project folder I get the following error message:

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)

I'm actually trying to expand the helloWorld project as an exercize, so I've added a postgres.json file in my helloWorld/WEB-INF/config folder. Here is the content of that file:

    {"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/"}
        }
}]
}

Could anyone tell me why persevere can't find that postgres driver please?

Thanks,
Lancelot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水溶 2024-07-23 15:09:19

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

Figured it out. The postgres driver jar should actually go into the folder: persevere/WEB-INF/lib instead of the persevere/lib.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文