Commit a035e879 authored by Quxl's avatar Quxl

x

parent a29e38e6
......@@ -30,8 +30,10 @@ public class SqlTestController {
private static final Logger logger = Logger.getLogger(ExceptionHandler.class);
@PostMapping("executeSql")
public Rjx doExecute(String jdbcUrl, String driverClass, String username, String password, String sql, String parameters) {
public Rjx doExecute(String jdbcUrl, String username, String password, String sql, String parameters) {
logger.debug(sql + " " + parameters);
DruidDataSource dataSource = new DruidDataSource();
new Thread() {
......@@ -47,6 +49,22 @@ public class SqlTestController {
}
}.start();
try {
String driverClass = null;
if(jdbcUrl.toLowerCase().contains("jtds")) {
driverClass = "net.sourceforge.jtds.jdbc.Driver";
} else if(jdbcUrl.contains("mysql")) {
driverClass = "com.mysql.jdbc.Driver";
} else if(jdbcUrl.contains("sqlserver")) {
driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
// } else if(jdbcUrl.contains("oracle")) {
// driverClass = "oracle.jdbc.driver.OracleDriver";
} else {
throw new XRException("URL无法识别, 没有对应的驱动程序");
}
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setUrl(jdbcUrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment