// 驱动
public String GetDriver(String url) {
try {
if (url.startsWith("jdbc:as400")) {
return "com.ibm.as400.access.AS400JDBCDriver";
} else if (url.startsWith("jdbc:oracle")) {
return "oracle.jdbc.driver.OracleDriver";
} else if (url.startsWith("jdbc:mysql")) {
return "com.mysql.cj.jdbc.Driver";
} else if (url.startsWith("jdbc:sqlserver")) {
return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
} else if (url.startsWith("jdbc:informix-sqli")) {
return "com.informix.jdbc.IfxDriver";
} else if(url.startsWith("jdbc:sybase")) {
return "com.sybase.jdbc4.jdbc.SybDriver";
}else if(url.startsWith("jdbc:db2")) {
return "com.ibm.db2.jcc.DB2Driver";
}else if(url.startsWith("jdbc:dm")) {
return "dm.jdbc.driver.DmDriver";
}else {
log.error("连接字符串有误:" + url);
return "";
}
} catch (Exception e) {
log.error("返回驱动异常:" + e);
return "";
}
}
com.tp.util.DataBaseRun : 连接:jdbc:oracle:thin:@xx.xx.xx.xx:1521/db 异常:java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
在并发较多的情况下,会出现错乱的情况。
如 oracle 的,会到 mysql 的类中去寻找。