问题描述
在项目中通过proxool配置jdbc连接sqlserver。配置文件如下:proxool.xml<?xml version="1.0" encoding="ISO-8859-1"?><something-else-entirely> <proxool> <alias>pool</alias> <driver-url>jdbc:sqlserver://localhost:1433;DatabaseName=xibowork</driver-url> <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class> <driver-properties> <property name="user" value="sa"/> <property name="password" value="密码"/> </driver-properties> <maximum-connection-count>1000</maximum-connection-count> <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql> </proxool></something-else-entirely>web.xml<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>ServletConfigurator</servlet-name> <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class> <init-param> <param-name>xmlFile</param-name> <param-value>WEB-INF/proxool.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- zh-cn encoding --> <filter> <filter-name>struts-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> </filter><filter-mapping><filter-name>struts-cleanup</filter-name><url-pattern>/*</url-pattern></filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping></web-app>最后通过Class.forName( "org.logicalcobwebs.proxool.ProxoolDriver" ); conn = DriverManager.getConnection("proxool.pool");获取连接,都是按照常规来配置的,myeclipse不报错。问题就来了。在运行到conn = DriverManager.getConnection("proxool.pool");即不报错也无法取得conn,就是说类似在这句话上假死了一样,求大牛解惑,急 问题补充:用jdbc直接连接是可以的 kidding87 写道
解决方案
ProxySelector.setDefault(null);在获取connection加上这句话试试
解决方案二:
你直接连试试看,可能是驱动的问题