提交 b89753f6 编写于 作者: S serge-rider

#9659 Oracle: extra NLS settings

上级 aa9087a0
......@@ -100,6 +100,9 @@ public class OracleUIMessages extends NLS {
public static String edit_label_combo_territory;
public static String edit_label_combo_territory_tool_tip_text;
public static String edit_label_text_date_format;
public static String edit_label_text_timestamp_format;
public static String edit_label_text_length_format;
public static String edit_label_text_currency_format;
public static String dialog_controlgroup_content;
public static String edit_create_checkbox_hide_empty_schemas;
public static String edit_create_checkbox_hide_empty_schemas_tool_tip_text;
......
......@@ -69,6 +69,9 @@ edit_label_combo_language_tool_tip_text = Session language
edit_label_combo_territory = Territory
edit_label_combo_territory_tool_tip_text = Session territory
edit_label_text_date_format = NLS Date Format
edit_label_text_timestamp_format = NLS Timestamp Format
edit_label_text_length_format = Length semantics
edit_label_text_currency_format = Currency symbol
dialog_controlgroup_content = Content
edit_create_checkbox_hide_empty_schemas = Hide empty schemas
edit_create_checkbox_hide_empty_schemas_tool_tip_text = Check existence of objects within schema and do not show empty schemas in tree.\nEnabled by default but it may cause performance problems on databases with very big number of objects.
......
......@@ -42,6 +42,9 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
private Combo languageCombo;
private Combo territoryCombo;
private Text nlsDateFormat;
private Text nlsTimestampFormat;
private Text nlsLengthFormat;
private Text nlsCurrencyFormat;
private Button hideEmptySchemasCheckbox;
private Button showDBAAlwaysCheckbox;
private Button useDBAViewsCheckbox;
......@@ -66,7 +69,7 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
public void createControl(Composite parent)
{
Composite cfgGroup = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 10;
gl.marginWidth = 10;
cfgGroup.setLayout(gl);
......@@ -75,6 +78,7 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
{
final Group sessionGroup = UIUtils.createControlGroup(cfgGroup, OracleUIMessages.dialog_controlgroup_session_settings, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
((GridData)sessionGroup.getLayoutData()).horizontalSpan = 2;
languageCombo = UIUtils.createLabelCombo(sessionGroup, OracleUIMessages.edit_label_combo_language, SWT.DROP_DOWN);
languageCombo.setToolTipText(OracleUIMessages.edit_label_combo_language_tool_tip_text);
......@@ -93,6 +97,9 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
territoryCombo.setText(OracleConstants.NLS_DEFAULT_VALUE);
nlsDateFormat = UIUtils.createLabelText(sessionGroup, OracleUIMessages.edit_label_text_date_format, "");
nlsTimestampFormat = UIUtils.createLabelText(sessionGroup, OracleUIMessages.edit_label_text_timestamp_format, "");
nlsLengthFormat = UIUtils.createLabelText(sessionGroup, OracleUIMessages.edit_label_text_length_format, "");
nlsCurrencyFormat = UIUtils.createLabelText(sessionGroup, OracleUIMessages.edit_label_text_currency_format, "");
}
{
......@@ -150,10 +157,10 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
territoryCombo.setText(nlsTerritory.toString());
}
final Object dateFormat = providerProperties.get(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT);
if (dateFormat != null) {
nlsDateFormat.setText(dateFormat.toString());
}
nlsDateFormat.setText(CommonUtils.toString(providerProperties.get(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT)));
nlsTimestampFormat.setText(CommonUtils.toString(providerProperties.get(OracleConstants.PROP_SESSION_NLS_TIMESTAMP_FORMAT)));
nlsLengthFormat.setText(CommonUtils.toString(providerProperties.get(OracleConstants.PROP_SESSION_NLS_LENGTH_FORMAT)));
nlsCurrencyFormat.setText(CommonUtils.toString(providerProperties.get(OracleConstants.PROP_SESSION_NLS_CURRENCY_FORMAT)));
final Object checkSchemaContent = providerProperties.get(OracleConstants.PROP_CHECK_SCHEMA_CONTENT);
if (checkSchemaContent != null) {
......@@ -187,12 +194,10 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
providerProperties.remove(OracleConstants.PROP_SESSION_TERRITORY);
}
String dateFormat = nlsDateFormat.getText().trim();
if (!dateFormat.isEmpty()) {
providerProperties.put(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT, dateFormat);
} else {
providerProperties.remove(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT);
}
setOrRemoveProperty(nlsDateFormat, OracleConstants.PROP_SESSION_NLS_DATE_FORMAT, providerProperties);
setOrRemoveProperty(nlsTimestampFormat, OracleConstants.PROP_SESSION_NLS_TIMESTAMP_FORMAT, providerProperties);
setOrRemoveProperty(nlsLengthFormat, OracleConstants.PROP_SESSION_NLS_LENGTH_FORMAT, providerProperties);
setOrRemoveProperty(nlsCurrencyFormat, OracleConstants.PROP_SESSION_NLS_CURRENCY_FORMAT, providerProperties);
providerProperties.put(
OracleConstants.PROP_CHECK_SCHEMA_CONTENT,
......@@ -224,4 +229,13 @@ public class OracleConnectionExtraPage extends ConnectionPageAbstract
saveConnectionURL(dataSource.getConnectionConfiguration());
}
private static void setOrRemoveProperty(Text text, String propName, Map<String, String> providerProperties) {
String propValue = text.getText().trim();
if (!propValue.isEmpty()) {
providerProperties.put(propName, propValue);
} else {
providerProperties.remove(propName);
}
}
}
......@@ -75,6 +75,9 @@ public class OracleConstants {
public static final String PROP_SESSION_LANGUAGE = DBConstants.INTERNAL_PROP_PREFIX + "session-language@";
public static final String PROP_SESSION_TERRITORY = DBConstants.INTERNAL_PROP_PREFIX + "session-territory@";
public static final String PROP_SESSION_NLS_DATE_FORMAT = DBConstants.INTERNAL_PROP_PREFIX + "session-nls-date-format@";
public static final String PROP_SESSION_NLS_TIMESTAMP_FORMAT = "session-nls-timestamp-format";
public static final String PROP_SESSION_NLS_LENGTH_FORMAT = "session-nls-length-format";
public static final String PROP_SESSION_NLS_CURRENCY_FORMAT = "session-nls-currency-format";
public static final String PROP_CHECK_SCHEMA_CONTENT = DBConstants.INTERNAL_PROP_PREFIX + "check-schema-content@";
public static final String PROP_ALWAYS_SHOW_DBA = DBConstants.INTERNAL_PROP_PREFIX + "always-show-dba@";
public static final String PROP_ALWAYS_USE_DBA_VIEWS = DBConstants.INTERNAL_PROP_PREFIX + "always-use-dba-views@";
......
......@@ -246,16 +246,10 @@ public class OracleDataSource extends JDBCDataSource implements DBPObjectStatist
log.warn("Can't set session territory", e);
}
}
String nlsDateFormat = connectionInfo.getProviderProperty(OracleConstants.PROP_SESSION_NLS_DATE_FORMAT);
if (nlsDateFormat != null) {
try {
JDBCUtils.executeSQL(
session,
"ALTER SESSION SET NLS_DATE_FORMAT='" + nlsDateFormat + "'");
} catch (Throwable e) {
log.warn("Can't set session NLS date format", e);
}
}
setNLSParameter(session, connectionInfo, "NLS_DATE_FORMAT", OracleConstants.PROP_SESSION_NLS_DATE_FORMAT);
setNLSParameter(session, connectionInfo, "NLS_TIMESTAMP_FORMAT", OracleConstants.PROP_SESSION_NLS_TIMESTAMP_FORMAT);
setNLSParameter(session, connectionInfo, "NLS_LENGTH_SEMANTICS", OracleConstants.PROP_SESSION_NLS_LENGTH_FORMAT);
setNLSParameter(session, connectionInfo, "NLS_CURRENCY", OracleConstants.PROP_SESSION_NLS_CURRENCY_FORMAT);
if (JDBCExecutionContext.TYPE_METADATA.equals(context.getContextName())) {
if (CommonUtils.toBoolean(connectionInfo.getProviderProperty(OracleConstants.PROP_USE_META_OPTIMIZER))) {
......@@ -273,6 +267,19 @@ public class OracleDataSource extends JDBCDataSource implements DBPObjectStatist
}
}
private void setNLSParameter(JDBCSession session, DBPConnectionConfiguration connectionInfo, String oraNlsName, String paramName) {
String paramValue = connectionInfo.getProviderProperty(paramName);
if (!CommonUtils.isEmpty(paramValue)) {
try {
JDBCUtils.executeSQL(
session,
"ALTER SESSION SET "+ oraNlsName + "='" + paramValue + "'");
} catch (Throwable e) {
log.warn("Can not set session NLS parameter " + oraNlsName, e);
}
}
}
public OracleSchema getDefaultSchema() {
return (OracleSchema) DBUtils.getDefaultContext(this, true).getContextDefaults().getDefaultSchema();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册