问一个问题,给代码也可以??JDBC和xml
来源:百度知道 编辑:UC知道 时间:2024/06/02 23:32:26
有相关的代码吗/谢谢了
这是getcon的一个类
public Connection getConnection(){
Connection connection;
Handinfo hf = new Handinfo();
Dbxml dx = new Dbxml();
try {
dx = hf.getDbxml("client");
} catch (Exception e1) {
throw new RuntimeException(e1);
}
String url = dx.getDburl();
String pasword = dx.getPasword();
String name = dx.getUserName();
String dv = dx.getDriver();
try {
Class.forName(dv);
connection = DriverManager.getConnection(url,name, pasword);
connection.setAutoCommit(false);
} catch (Exception e) {
throw new RuntimeException(e) ;
}
return connection;
}
public void closeConnection(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
}
}
}
public void rollbackConnection(Connection connection) {
if (connec