当前位置: 代码迷 >> J2SE >> [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.解决思路
  详细解决方案

[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.解决思路

热度:10725   发布时间:2013-02-25 00:00:00.0
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
数据库操作时报这个错是怎么回事?
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 java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.ibatis.common.jdbc.SimpleDataSource.popConnection(SimpleDataSource.java:580)
at com.ibatis.common.jdbc.SimpleDataSource.getConnection(SimpleDataSource.java:222)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.init(JdbcTransaction.java:48)
at com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:89)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)
at com.zzr.main.Test.main(Test.java:39)




  public class Test {

/**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
String resource ="com/zzr/resource/SqlMapConfig.xml";
Reader reader= null;
SqlMapClient sqlMap = null;
try{
reader = Resources.getResourceAsReader( resource );
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader); 

//sqlMap系统初始化完毕,开始执行update操作

// sqlMap.startTransaction();
// User user = new User();
// user.setId(new Integer(1));
// user.setName("Erica");
// user.setSex(new Integer(1));
// sqlMap.update("updateUser",user);
// sqlMap.commitTransaction();

sqlMap.startTransaction();
String name = new String("selina");
User user = (User)sqlMap.queryForObject("getUser", name);

sqlMap.commitTransaction();
}catch(Exception ex){
ex.printStackTrace();
}
finally{
try{
sqlMap.endTransaction();
}catch(SQLException ex){
ex.printStackTrace();
}
  
}
}
}



//============User.xml =======

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="User">
<typeAlias alias="user" type="com.zzr.entiy.User"/>
<select id="getUser" parameterClass="java.lang.String" resultClass="user">
  相关解决方案