朋友的金政程序,打不开。以下是错误日志,请求各位高手帮帮忙。========================================================SQLException occurred in JDBCPool: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
params: com.microsoft.jdbc.sqlserver.SQLServerDriver, jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=hr. Please check your username, password and other connectivity info.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at com.codestudio.util.JDBCPool.create(Unknown Source)
at com.codestudio.util.ObjectPool.checkOut(Unknown Source)
at com.codestudio.util.ObjectPool.init(Unknown Source)
at com.codestudio.util.JDBCPool.init(Unknown Source)
at com.codestudio.util.JDBCPool.<init>(Unknown Source)
at com.codestudio.util.SQLManager.createPool(Unknown Source)
at com.codestudio.management.LocalPoolDeployer.startDataSources(Unknown Source)
at com.codestudio.management.LocalPoolDeployer.deployConfiguration(Unknown Source)
at com.codestudio.management.PoolManBootstrap.<init>(Unknown Source)
at com.codestudio.util.SQLManager.assertLoaded(Unknown Source)
at com.codestudio.util.SQLManager.getPoolByJNDIName(Unknown Source)
at com.codestudio.sql.PoolMan.findDataSource(Unknown Source)=============================================================
以下是数据库连接的XML文件:D:\web\webapps\hr\WEB-INF\classes
=============================================================
<?xml version="1.0" encoding="UTF-8"?><poolman> <management-mode>local</management-mode> <!-- ========================================================== -->
<!-- These entries are simple examples of minimal JDBC -->
<!-- Connection pools. Many of the parameters are optional, and -->
<!-- there are *many* more parameters available. Consult the -->
<!-- UsersGuide.html document and the poolman.xml.template file -->
<!-- for guidance and element definitions. -->
<!-- ========================================================== -->
<!-- EXAMPLE 1: A minimally-configured database example -->
<datasource> <dbname>database</dbname>
<jndiName>jndi-testdatabase</jndiName>
<driver>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver>
<url>jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=hr;</url> <username>hr</username>
<password>mjj</password> <nativeResults>true</nativeResults>
<minimumSize>10</minimumSize>
<maximumSize>1000</maximumSize>
<maximumSoft>true</maximumSoft> <connectionTimeout>600</connectionTimeout>
<userTimeout>12</userTimeout>
<shrinkBy>7</shrinkBy>
<debugging>true</debugging>
<logFile>C:\dblog</logFile> </datasource></poolman>
=======================================================谢谢各位朋友!
params: com.microsoft.jdbc.sqlserver.SQLServerDriver, jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=hr. Please check your username, password and other connectivity info.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at com.codestudio.util.JDBCPool.create(Unknown Source)
at com.codestudio.util.ObjectPool.checkOut(Unknown Source)
at com.codestudio.util.ObjectPool.init(Unknown Source)
at com.codestudio.util.JDBCPool.init(Unknown Source)
at com.codestudio.util.JDBCPool.<init>(Unknown Source)
at com.codestudio.util.SQLManager.createPool(Unknown Source)
at com.codestudio.management.LocalPoolDeployer.startDataSources(Unknown Source)
at com.codestudio.management.LocalPoolDeployer.deployConfiguration(Unknown Source)
at com.codestudio.management.PoolManBootstrap.<init>(Unknown Source)
at com.codestudio.util.SQLManager.assertLoaded(Unknown Source)
at com.codestudio.util.SQLManager.getPoolByJNDIName(Unknown Source)
at com.codestudio.sql.PoolMan.findDataSource(Unknown Source)=============================================================
以下是数据库连接的XML文件:D:\web\webapps\hr\WEB-INF\classes
=============================================================
<?xml version="1.0" encoding="UTF-8"?><poolman> <management-mode>local</management-mode> <!-- ========================================================== -->
<!-- These entries are simple examples of minimal JDBC -->
<!-- Connection pools. Many of the parameters are optional, and -->
<!-- there are *many* more parameters available. Consult the -->
<!-- UsersGuide.html document and the poolman.xml.template file -->
<!-- for guidance and element definitions. -->
<!-- ========================================================== -->
<!-- EXAMPLE 1: A minimally-configured database example -->
<datasource> <dbname>database</dbname>
<jndiName>jndi-testdatabase</jndiName>
<driver>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver>
<url>jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=hr;</url> <username>hr</username>
<password>mjj</password> <nativeResults>true</nativeResults>
<minimumSize>10</minimumSize>
<maximumSize>1000</maximumSize>
<maximumSoft>true</maximumSoft> <connectionTimeout>600</connectionTimeout>
<userTimeout>12</userTimeout>
<shrinkBy>7</shrinkBy>
<debugging>true</debugging>
<logFile>C:\dblog</logFile> </datasource></poolman>
=======================================================谢谢各位朋友!
咋看,貌似你的 <username>hr </username>以及 <password>mjj </password>密码这里多了空格!呵呵!
这个是csdn的问题,没关系的。
jdbc:sqlserver://127.0.0.1:1433;DatabaseName=hr
试一试
<url>jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=hr; </url>
复制到CSDN的编辑器里,自动加的。谢谢
* @param args
*/
public static void main(String...a) throws Exception {
try {
// TODO Auto-generated method stub
final String url = "jdbc:microsoft:sqlserver://192.168.1.104:1433;databaseName=temp4yb";
final String user = "sa";
final String passwd = ""; Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
.newInstance(); Connection con = DriverManager.getConnection(url, user, passwd);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM tuser");
while (rs.next())
System.out.println(rs.getString("usercd"));
} catch (Exception e) {
e.printStackTrace(System.err);
} }
}你用上面这段,把参数改一下就行了。
另外,那个";"千万别去,没那个不行的。
连接串应为:jdbc:sqlserver://127.0.0.1:1433;databaseName=hr;