在使用tomcat时数据库连接不上
我用的是Spring+Mybatis,配置文件写的没问题,昨天也连上了,今天就一直报错严重:Servlet.service()forservlet[springmvc]i...
我用的是Spring+Mybatis,配置文件写的没问题,昨天也连上了,今天就一直报错
严重: Servlet.service() for servlet [springmvc] in context with path [/help] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)
### The error may exist in file [E:\tomcat\apache-tomcat-7.0.47\apache-tomcat-7.0.47\webapps\help\WEB-INF\classes\org\xxxx\entity\Personl.xml]
### The error may involve org.xxxx.dao.PersonDao.findAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)] with root cause
java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:494)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33) 展开
严重: Servlet.service() for servlet [springmvc] in context with path [/help] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)
### The error may exist in file [E:\tomcat\apache-tomcat-7.0.47\apache-tomcat-7.0.47\webapps\help\WEB-INF\classes\org\xxxx\entity\Personl.xml]
### The error may involve org.xxxx.dao.PersonDao.findAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)] with root cause
java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:494)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33) 展开
3个回答
展开全部
出现这个是因为你的数据库没有连接上导致的,检查以下几个地方
1.你的db.properties文件是否配置正确 useUnicode=true&&characterEncoding=UTF-8表示你设置的编码为utf-8保证与数据库的一致 防止乱码
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql://localhost:3306/oa?unicode=true&characterEncoding=utf-8
jdbc.user=root
jdbc.password=111
2.检查你的spring/applicationContext-dao.xml是否配置了数据源,而且是否配置正确
<!--加载properties配置文件-->
<context:property-placeholder location="classpath:properties/dbinfo.properties"></context:property-placeholder>
3.你的连接名是否是正确的和你在db.properties中配置的是否一样
<!--加载properties配置文件-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
4.你电脑中的服务是否打开
5.检查下的你数据库名是否存在,或者表是否存在
展开全部
The Network Adapter could not establish the connection 这里已经说明了无法访问数据库服务器,所以检查两点:
1.oracle服务正常运行
2.oracle驱动正常加载
按照你的描述,第一种可能性最大,重启Oracle服务试试
1.oracle服务正常运行
2.oracle驱动正常加载
按照你的描述,第一种可能性最大,重启Oracle服务试试
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
对于Windows Server来说,一般情况一个月重启一次是正常的,但是用几天就重启就存在问题了。
具体原因也不敢肯定。
建议你认真检查你的程序,看是不是存在问题。
以上回答你满意么?
具体原因也不敢肯定。
建议你认真检查你的程序,看是不是存在问题。
以上回答你满意么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询