日期:2014-05-18 浏览次数:20806 次
public static Boolean changeDataSource(Map map) {
DriverManagerDataSource basicDS = (DriverManagerDataSource) createBean("dataSourceTrends");
basicDS.setUsername((String) map.get("sa"));
basicDS.setPassword((String) map.get("password"));
String url = "jdbc:sqlserver://" + (String) map.get("ip") + ":"
+ (String) map.get("port") + ";DatabaseName="
+ (String) map.get("DatabaseName");
basicDS.setUrl(url);
/* if (map.get("areacode").toString().equals("420300")) {
basicDS.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");// sql2005
System.out.println("**********sql2005**********");
} else {
basicDS.setDriverClassName("com.microsoft.jdbc.sqlserver.SQLServerDriver");// sql2000
System.out.println("**********sql2000**********");
}*/
Boolean isCon;
try {
// isCon = basicDS.getConnection();
// int is = basicDS.getLoginTimeout();
// System.out.println("is :"+ is);
System.out.println(url);
if (basicDS.getConnection() != null)
System.out.println("******************远程数据库连接初始化成功!!*******************");
} catch (SQLException e) {
FileWriter fileWriter = null;
PrintWriter printWriter = null;
Date now = new Date();
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.LONG);
// DateFormat d1 = DateFormat.getDateInstance();
// //默认语言(汉语)下的默认风格(MEDIUM风格,比如:2008-6-16 20:54:53)
try {
fileWriter = new FileWriter("d:/4201/DBConnectLog.txt", true);
printWriter = new PrintWriter(fileWriter);
printWriter.println(df.format(now) + "--:" + url + " 没有连接上");
printWriter.close();
fileWriter.close();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (printWriter != null) {
printWriter.close();
}
if (fileWriter != null) {
try {
fileWriter.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return false;
}
return true;
}
[ERROR][2013-11-14 11:07:57,515][http-8989-8][org.hibernate.util.JDBCExceptionReporter][Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。参数 1 (""): 数据类型 0x38 未知。
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.h