mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
+8
-1
@@ -3,4 +3,11 @@
|
||||
/.project
|
||||
/.classpath
|
||||
/1
|
||||
/derby.log
|
||||
/derby.log
|
||||
|
||||
# IntelliJ Idea
|
||||
.idea/
|
||||
out/
|
||||
*.ipr
|
||||
*.iws
|
||||
*.iml
|
||||
@@ -17,8 +17,10 @@ package com.alibaba.druid.filter.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.PublicKey;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
@@ -231,22 +233,29 @@ public class ConfigFilter extends FilterAdapter {
|
||||
InputStream inStream = null;
|
||||
try {
|
||||
boolean xml = false;
|
||||
if (filePath.startsWith("http://") || filePath.startsWith("https://") || filePath.startsWith("file://")) {
|
||||
if (filePath.startsWith("http://") || filePath.startsWith("https://") || filePath.startsWith("file://")) {
|
||||
URL url = new URL(filePath);
|
||||
inStream = url.openStream();
|
||||
try {
|
||||
inStream = url.openStream();
|
||||
xml = url.getPath().endsWith(".xml");
|
||||
} catch (UnknownHostException e) {
|
||||
// 处理本地的文件,格式:file://C:\Users\UserName\AppData\Local\Temp\MyTest6192238555052741793919301884303
|
||||
if(url.getHost().length() == 1 && filePath.startsWith("file://")) {
|
||||
filePath = filePath.substring("file://".length());
|
||||
inStream = getFileAsStream(filePath);
|
||||
xml = filePath.endsWith(".xml");
|
||||
} else {
|
||||
throw new UnknownHostException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
xml = url.getPath().endsWith(".xml");
|
||||
} else if (filePath.startsWith("classpath:")) {
|
||||
String resourcePath = filePath.substring("classpath:".length());
|
||||
inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath);
|
||||
// 在classpath下应该也可以配置xml文件吧?
|
||||
xml = resourcePath.endsWith(".xml");
|
||||
} else {
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
inStream = new FileInputStream(file);
|
||||
} else {
|
||||
inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
|
||||
}
|
||||
|
||||
inStream = getFileAsStream(filePath);
|
||||
xml = filePath.endsWith(".xml");
|
||||
}
|
||||
|
||||
@@ -269,4 +278,15 @@ public class ConfigFilter extends FilterAdapter {
|
||||
JdbcUtils.close(inStream);
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getFileAsStream(String filePath) throws FileNotFoundException {
|
||||
InputStream inStream = null;
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
inStream = new FileInputStream(file);
|
||||
} else {
|
||||
inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
|
||||
}
|
||||
return inStream;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -192,10 +192,12 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
return;
|
||||
}
|
||||
|
||||
if (x.getParent() != null) {
|
||||
print(";");
|
||||
} else {
|
||||
println(";");
|
||||
if(isPrettyFormat()) {
|
||||
if (x.getParent() != null) {
|
||||
print(";");
|
||||
} else {
|
||||
println(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,14 +447,14 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
|
||||
print("CONNECT BY ");
|
||||
|
||||
if (x.isPrior()) {
|
||||
print("PRIOR ");
|
||||
}
|
||||
|
||||
if (x.isNoCycle()) {
|
||||
print("NOCYCLE ");
|
||||
}
|
||||
|
||||
if (x.isPrior()) {
|
||||
print("PRIOR ");
|
||||
}
|
||||
|
||||
x.getConnectBy().accept(this);
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user