当前位置: 代码迷 >> Java Web开发 >> javax.faces.el.EvaluationException: java.sql.SQLException: Io 异常:
  详细解决方案

javax.faces.el.EvaluationException: java.sql.SQLException: Io 异常:

热度:627   发布时间:2016-04-17 17:16:26.0
100分:Spring JDBC Io 异常: Connection reset
请各位大侠帮忙看看~~
我在beans-config.xml中这样配置dataSource:
XML code
<bean id="dataSource"      class="org.springframework.jdbc.datasource.DriverManagerDataSource">      <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>      <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:TDMS"/>      <property name="username" value="system"/>      <property name="password" value="huangdezhi"/>  </bean>

然后在java文件中使用Spring的JdbcTemplate对象:
Java code
jdbcTemplate.update("INSERT INTO DATABASES (DBNAME, DBPASSWORD, DBCREATOR, DBDESCRIPTION)"                + "VALUES('" + name + "','" + password + "','" + creator + "','" + description + "')");

然后运行时,tomcat抛出了这样的异常:
严重: java.sql.SQLException: Io 异常: Connection reset
javax.faces.el.EvaluationException: java.sql.SQLException: Io 异常: Connection reset
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:97)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
…………
Caused by: java.sql.SQLException: Io 异常: Connection reset
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:281)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:269)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:253)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:234)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:522)
at thesis.tdms.createDB.CreateDB.create(CreateDB.java:30)
…………

我是在哪儿写错了吗?那个异常看得我一头雾水。。。请各位帮帮忙啦。


------解决方案--------------------
严重: java.sql.SQLException: Io 异常: Connection reset 

是你的连接写错了,也许是url,也许是用户名和密码。

如果服务器不在你本机,你远程连数据库,那么我更怀疑是防火墙问题。
------解决方案--------------------
端口连接失败就是LISTENER服务没有打开,在服务里找到ORACLE的LISTENER启动就行了。
  相关解决方案