日期:2014-05-17  浏览次数:21488 次

使用postgresql JDBC出现的错误org.postgresql.util.PSQLException: 尝试连线已失败
使用论坛中一个朋友的系统,通过myeclipse启动tomcat时出现了以下错误:

询问下有没有熟悉这个数据库的,遇到过这种问题么,另外是不是proxool配置的有问题,求解?

以下是proxool.xml文件的配置信息
XML code

<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
  <proxool>
    <alias>proxooldatascr</alias>
    <driver-url>jdbc:postgresql://localhost/bhtec</driver-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <driver-properties>
      <property name="user" value="postgres"/>
      <property name="password" value="123456"/>
    </driver-properties>
     
     <!-- 
    <driver-url>jdbc:mysql://localhost:3306/bhtec?characterEncoding=utf-8</driver-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <driver-properties>
      <property name="user" value="mysql"/>
      <property name="password" value="123456"/>
    </driver-properties>
    -->
    <maximum-connection-count>100</maximum-connection-count>
    <minimum-connection-count>10</minimum-connection-count>
    <house-keeping-sleep-time>90000</house-keeping-sleep-time>
    <maximum-new-connections>20</maximum-new-connections>
    <prototype-count>5</prototype-count>
    <test-before-use>true</test-before-use>
    <house-keeping-test-sql>select current_date</house-keeping-test-sql>
  </proxool>
</something-else-entirely>




------解决方案--------------------
异常堆栈没有给全啊

很多时候 java.net.SocketException: Connection Reset
是应用层协议的一个错误,己方尝试读取流中数据,但对方已经关闭连接,可能正常关闭也可能异常关闭,原因多种多样,可能数据库连接根本就没建立起来,具体配置不清楚



 
------解决方案--------------------
1. 首先你确定你的数据库是开着的,保证可以连接上。
2. 确定你是jar和url连接数据库没问题。
3. 程序里面的问题不大,还是在你连接数据库这里。
你可以写个简单的jdbc连接试试看。