我们知道micro的sql server jdbc驱动限制了记录的回读功能,这样开发的过程会经常出现错误,所以有了opensource的jtds.jar,使用方法见下:
package bean;
import java.sql.*;
public class ConnectSqlserver {
private String driverClass = "net.sourceforge.jtds.jdbc.Driver";
private String url ="jdbc:jtds:sqlserver://localhost:1433/award";
private String user = "test";
private String password = "riskfitfeng";
private Connection connection;
public ConnectSqlserver() {
}
public Connection openConnection() throws SQLException {
try {
Class.forName(driverClass);
connection = DriverManager.getConnection(url, user, password);
return connection;
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
public void closeConnection() {
try {
if (connection != null)
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
posted on 2009-06-02 14:10
fl1429 阅读(4857)
评论(0) 编辑 收藏 所属分类:
Jsp/Servlet/Javabean