我會嘗試盡我所能來制定。tomcat服務器上的jdbc連接
首先,Web應用程序(Spring MVC中使用Spring JDBC)運作良好,直到我開始搞亂了與STS(基於Eclipse的春天工具套件)和JDK + JRE7的版本,以獲取Java 7
二的特點,目前的問題是Apache Tomcat 6或7(我因爲我不記得的原因而重新安裝了這兩個東西)似乎正在影響與數據庫的連接。直接說:它未能得到JDBC連接
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:postgresql:postgres
和它發生時,我嘗試從我的web應用程序做數據庫的任何操作。
行jdbc:postgresql:postgres以防萬一,因爲它工作之前,它有效地說連接到本地數據庫與名稱postgres(也因爲下面的點)。
另一個值得一提的重要的事情是,在vFabric tc服務器下,一切都完美無缺地工作,沒有任何問題。
第三,數據庫是PostgreSql以及Apache DBCP池。第四,maven jdbc驅動程序的依賴關係似乎很好,再次如果他們沒有vFabric tc Server也會導致Apache Tomcat失敗,這導致我想到Apache Tomcat本身就是罪魁禍首。
一些服務器過程中產生的信息的啓動:
Dec 14, 2011 4:54:32 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\ProgramFiles\Java\jdk1.7.0_02\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;.
Dec 14, 2011 4:54:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 14, 2011 4:54:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 14, 2011 4:54:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 849 ms
Dec 14, 2011 4:54:32 PM org.apache.catalina.core.StandardServicestartInternal
INFO: Starting service Catalina
Dec 14, 2011 4:54:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Dec 14, 2011 4:54:33 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\Users\User\Documents\workspace-sts\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\project.xml
Dec 14, 2011 4:54:33 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:project' did not find a matching property.
Dec 14, 2011 4:54:34 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Dec 14, 2011 4:54:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 14, 2011 4:54:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 14, 2011 4:54:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4664 ms
我真的很絕望,請幫助。
UPDATE:
依然坐在前面看着傷心的畫面,所以我決定把所有的.xml配置。
<bean id="dataSource" class="org.apache.commons.dbcp.PoolingDataSource">
<constructor-arg ref="connectionPool"/>
</bean>
<bean id ="connectionPool" class="org.apache.commons.pool.impl.GenericObjectPool">
<constructor-arg><null/></constructor-arg>
</bean>
<bean id="poolableConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionFactory" >
<constructor-arg ref="connectionFactory"/>
<constructor-arg ref="connectionPool"/>
<constructor-arg><null/></constructor-arg>
<constructor-arg><null/></constructor-arg>
<constructor-arg value="false"/>
<constructor-arg value="true"/>
</bean>
<bean id="connectionFactory" class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
<constructor-arg value="jdbc:postgresql:postgres"/>
<constructor-arg value="postgres"/>
<constructor-arg value="myCorrectPassword"/>
</bean>
你是如何加載驅動程序? – PseudoNinja 2011-12-14 17:06:31
在春季配置文件中接線,你要我發貼嗎? – Aubergine 2011-12-14 17:09:56