import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.tianque.exception.base.ServiceValidationException;
public final class DbTools {
private static Logger log = LoggerFactory.getLogger(DbTools.class);
private DbTools() {
}
/**
* 根据数据库连接参数生成数据库连接对象
*
* @param mapDb
* {DS_URL:"",DS_USER:"",DS_PASS:"",DS_CS:"10"}
* @return 返回数据库连接对象
*/
public static Connection getConnection(Map mapDb) {
String dsUrl = MapUtils.getString(mapDb, "DS_URL");
String driver = "oracle.jdbc.driver.OracleDriver";
if (dsUrl.indexOf("mysql") != -1) {
driver = "com.mysql.jdbc.Driver";
}
if (dsUrl.indexOf("sqlserver") != -1) {
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
Connection conn = null;
Properties props = new Prope