我是新手要坚持下去,我做了helloWorld教程,非常令人印象深刻,但我现在正试图连接到一个真正的postgres数据库,并发现自己很难让我认识的驱动程序,我觉得它应该是死的简单。
我删除了所有用于postgres的jdbc驱动程序到persevere / lib文件夹:
然而,当我开始坚持使用命令“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司机?
谢谢, 兰斯洛特。
答案 0 :(得分:0)
想出来。 postgres驱动程序jar实际上应该进入文件夹:persevere / WEB-INF / lib而不是persevere / lib。