|
|
@ -51,9 +51,10 @@ public class JDBCDefPane extends JPanel { |
|
|
|
public static final String DRIVER_TYPE = "driver_type"; |
|
|
|
public static final String DRIVER_TYPE = "driver_type"; |
|
|
|
public static final String USER_NAME = "user_name"; |
|
|
|
public static final String USER_NAME = "user_name"; |
|
|
|
private static final String OTHER_DB = "Others"; |
|
|
|
private static final String OTHER_DB = "Others"; |
|
|
|
private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE); |
|
|
|
private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE); |
|
|
|
private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE); |
|
|
|
private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE); |
|
|
|
private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$"); |
|
|
|
private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$"); |
|
|
|
|
|
|
|
private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]"); |
|
|
|
// 编码转换.
|
|
|
|
// 编码转换.
|
|
|
|
private String originalCharSet = null; |
|
|
|
private String originalCharSet = null; |
|
|
|
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>(); |
|
|
|
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>(); |
|
|
@ -389,6 +390,9 @@ public class JDBCDefPane extends JPanel { |
|
|
|
InputMethodListener portInputMethodListener = new InputMethodListener() { |
|
|
|
InputMethodListener portInputMethodListener = new InputMethodListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void inputMethodTextChanged(InputMethodEvent event) { |
|
|
|
public void inputMethodTextChanged(InputMethodEvent event) { |
|
|
|
|
|
|
|
if (null == event.getText()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
char ch = event.getText().current(); |
|
|
|
char ch = event.getText().current(); |
|
|
|
if (!(ch >= '0' && ch <= '9')) { |
|
|
|
if (!(ch >= '0' && ch <= '9')) { |
|
|
|
event.consume(); |
|
|
|
event.consume(); |
|
|
@ -484,13 +488,13 @@ public class JDBCDefPane extends JPanel { |
|
|
|
KeyListener portKeyListener = new KeyAdapter() { |
|
|
|
KeyListener portKeyListener = new KeyAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
String port = portTextField.getText().trim(); |
|
|
|
String port = portTextField.getText(); |
|
|
|
if (isPortValid(port)) { |
|
|
|
if (isPortValid(port)) { |
|
|
|
updateURL(); |
|
|
|
updateURL(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
portTextField.setText(port.replaceAll(e.getKeyChar() + "", "")); |
|
|
|
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , "")); |
|
|
|
if (!isPortValid(portTextField.getText())) { |
|
|
|
if (!isPortValid(portTextField.getText())) { |
|
|
|
portTextField.setText(""); |
|
|
|
portTextField.setText(StringUtils.EMPTY); |
|
|
|
updateURL(); |
|
|
|
updateURL(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -501,6 +505,15 @@ public class JDBCDefPane extends JPanel { |
|
|
|
return PORT.matcher(port).find(); |
|
|
|
return PORT.matcher(port).find(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getCharNeedReplace(char c) { |
|
|
|
|
|
|
|
String charNeedReplace = c + ""; |
|
|
|
|
|
|
|
Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace); |
|
|
|
|
|
|
|
if (matcher.find()) { |
|
|
|
|
|
|
|
charNeedReplace = "\\" + charNeedReplace; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return charNeedReplace; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DocumentListener updateURLListener = new DocumentListener() { |
|
|
|
DocumentListener updateURLListener = new DocumentListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|