Spring JDBC连接问题 - 无法从底层数据库获取Connections

时间:2015-07-21 13:28:18

标签: java spring spring-mvc jdbc

我遇到了一个很大的麻烦,我无法连接我的Spring MVC应用程序的oracle 11g数据库。 我得到的错误是

// Summary:
//     Specifies the day of the week.
[Serializable]
[ComVisible(true)]
public enum DayOfWeek
{
    // Summary:
    //     Indicates Sunday.
    Sunday = 0,
    //
    // Summary:
    //     Indicates Monday.
    Monday = 1,
    //
    // Summary:
    //     Indicates Tuesday.
    Tuesday = 2,
    //
    // Summary:
    //     Indicates Wednesday.
    Wednesday = 3,
    //
    // Summary:
    //     Indicates Thursday.
    Thursday = 4,
    //
    // Summary:
    //     Indicates Friday.
    Friday = 5,
    //
    // Summary:
    //     Indicates Saturday.
    Saturday = 6,
}

也 在堆栈跟踪中我得到了错误 -

HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

如果您可以帮助我解决问题,那将是一个很大的帮助。 我在下面提供我的配置和编码详情:

  

默认-servlet.xml中

java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
  

UserAuthenticationRepositoryImpl.java

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
    <property name="minPoolSize" value="${jdbc.minPoolSize}" />
    <property name="maxStatements" value="${jdbc.maxStatements}" />
    <property name="testConnectionOnCheckout" value="${jdbc.testConnection}" />
</bean>

<bean id="userAuthenticationRepository" 
            class="com.era.repository.impl.UserAuthenticationRepositoryImpl">

    <property name="dataSource" ref="dataSource" />
</bean>

public class UserAuthenticationRepositoryImpl实现UserAuthenticationRepository {

@Repository

enter image description here enter image description here

1 个答案:

答案 0 :(得分:2)

当您使用maven时,请注意,由于 license 限制,您无法直接将Oracle驱动程序jar发送到.m2,因此您可能需要手动下载并将其放置到您的存储库。您可能会发现此^= means starts with.有用。