use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DataHandler method getConnectionSpecificInfo.
protected void getConnectionSpecificInfo(DatabaseMeta meta) {
// Hostname:
if (hostNameBox != null) {
meta.setHostname(hostNameBox.getValue());
}
// Database name:
if (databaseNameBox != null) {
meta.setDBName(databaseNameBox.getValue());
}
// Username:
if (userNameBox != null) {
meta.setUsername(userNameBox.getValue());
}
// Password:
if (passwordBox != null) {
meta.setPassword(passwordBox.getValue());
}
if (databaseDialectList != null) {
DatabaseInterface databaseInterface = meta.getDatabaseInterface();
if (databaseInterface instanceof GenericDatabaseMeta) {
((GenericDatabaseMeta) databaseInterface).setDatabaseDialect(databaseDialectList.getValue());
}
}
// Streaming result cursor:
if (resultStreamingCursorCheck != null) {
meta.setStreamingResults(resultStreamingCursorCheck.isChecked());
}
// Data tablespace:
if (dataTablespaceBox != null) {
meta.setDataTablespace(dataTablespaceBox.getValue());
}
// Index tablespace
if (indexTablespaceBox != null) {
meta.setIndexTablespace(indexTablespaceBox.getValue());
}
if (serverInstanceBox != null) {
meta.setSQLServerInstance(serverInstanceBox.getValue());
if (optionsParameterTree != null && optionsParameterTree.getRootChildren() != null) {
for (int i = 0; i < optionsParameterTree.getRootChildren().getItemCount(); i++) {
XulTreeItem potRow = optionsParameterTree.getRootChildren().getItem(i);
if (potRow != null && potRow.getRow() != null) {
XulTreeCell cell = potRow.getRow().getCell(0);
XulTreeCell cell2 = potRow.getRow().getCell(1);
if (cell != null && cell.getLabel() != null && cell.getLabel().equals("instance")) {
cell2.setLabel(serverInstanceBox.getValue());
if (serverInstanceBox.getValue().trim().length() == 0) {
cell.setLabel("");
}
}
}
}
}
}
// SQL Server double decimal separator
if (doubleDecimalSeparatorCheck != null) {
meta.setUsingDoubleDecimalAsSchemaTableSeparator(doubleDecimalSeparatorCheck.isChecked());
}
// SAP Attributes...
if (languageBox != null) {
meta.getAttributes().put("SAPLanguage", languageBox.getValue());
}
if (systemNumberBox != null) {
meta.getAttributes().put("SAPSystemNumber", systemNumberBox.getValue());
}
if (clientBox != null) {
meta.getAttributes().put("SAPClient", clientBox.getValue());
}
// Snowflake
if (warehouseBox != null) {
meta.getAttributes().put(WAREHOUSE, warehouseBox.getValue());
}
// Generic settings...
if (customUrlBox != null) {
meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, customUrlBox.getValue());
}
if (customDriverClassBox != null) {
meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, customDriverClassBox.getValue());
}
// Server Name: (Informix)
if (serverNameBox != null) {
meta.setServername(serverNameBox.getValue());
}
// Microsoft SQL Server Use Integrated Security
if (useIntegratedSecurityCheck != null) {
Boolean useIntegratedSecurity = useIntegratedSecurityCheck.isChecked();
meta.getAttributes().put(MSSQLServerNativeDatabaseMeta.ATTRIBUTE_USE_INTEGRATED_SECURITY, useIntegratedSecurity != null ? useIntegratedSecurity.toString() : "false");
}
// Azure SQL DB
if (azureSqlDBJdbcAuthMethod != null) {
meta.getAttributes().put(JDBC_AUTH_METHOD, azureSqlDBJdbcAuthMethod.getValue());
}
if (azureSqlDBClientSecretId != null) {
meta.getAttributes().put(CLIENT_ID, azureSqlDBClientSecretId.getValue());
}
if (azureSqlDBAlwaysEncryptionEnabled != null) {
if (azureSqlDBAlwaysEncryptionEnabled.isChecked()) {
meta.getAttributes().put(IS_ALWAYS_ENCRYPTION_ENABLED, "true");
} else {
meta.getAttributes().put(IS_ALWAYS_ENCRYPTION_ENABLED, "false");
}
}
if (azureSqlDBClientSecretKey != null) {
meta.getAttributes().put(CLIENT_SECRET_KEY, azureSqlDBClientSecretKey.getValue());
}
if (jdbcAuthMethod != null) {
meta.getAttributes().put(JDBC_AUTH_METHOD, jdbcAuthMethod.getValue());
}
if (iamAccessKeyId != null) {
meta.getAttributes().put(IAM_ACCESS_KEY_ID, iamAccessKeyId.getValue());
}
if (iamSecretKeyId != null) {
meta.getAttributes().put(IAM_SECRET_ACCESS_KEY, Encr.encryptPassword(iamSecretKeyId.getValue()));
}
if (iamSessionToken != null) {
meta.getAttributes().put(IAM_SESSION_TOKEN, iamSessionToken.getValue());
}
if (iamProfileName != null) {
meta.getAttributes().put(IAM_PROFILE_NAME, iamProfileName.getValue());
}
if (webAppName != null) {
meta.setDBName(webAppName.getValue());
}
if (namedClusterList != null) {
meta.getDatabaseInterface().setNamedCluster(namedClusterList.getValue());
}
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class FragmentHandlerTest method testRefreshOptions.
@Test
public void testRefreshOptions() throws Exception {
XulListbox connectionBox = mock(XulListbox.class);
when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
when(connectionBox.getSelectedItem()).thenReturn("myDb");
XulListbox accessBox = mock(XulListbox.class);
when(document.getElementById("access-type-list")).thenReturn(accessBox);
when(accessBox.getSelectedItem()).thenReturn("Native");
DataHandler dataHandler = mock(DataHandler.class);
when(xulDomContainer.getEventHandler("dataHandler")).thenReturn(dataHandler);
DatabaseInterface dbInterface = mock(DatabaseInterface.class);
when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
DataHandler.connectionMap.put("myDb", dbInterface);
XulComponent component = mock(XulComponent.class);
XulComponent parent = mock(XulComponent.class);
when(component.getParent()).thenReturn(parent);
when(document.getElementById("database-options-box")).thenReturn(component);
XulDomContainer fragmentContainer = mock(XulDomContainer.class);
Document mockDoc = mock(Document.class);
XulComponent firstChild = mock(XulComponent.class);
when(mockDoc.getFirstChild()).thenReturn(firstChild);
when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
XulTextbox portBox = mock(XulTextbox.class);
when(document.getElementById("port-number-text")).thenReturn(portBox);
fragmentHandler.refreshOptions();
// Iterate through the other database access types
when(accessBox.getSelectedItem()).thenReturn("JNDI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("ODBC");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("OCI");
fragmentHandler.refreshOptions();
when(accessBox.getSelectedItem()).thenReturn("Plugin");
fragmentHandler.refreshOptions();
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DataHandlerTest method testLoadConnectionData.
@Test
public void testLoadConnectionData() throws Exception {
DatabaseInterface dbInterface = mock(DatabaseInterface.class);
when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
DataHandler.connectionMap.put("myDb", dbInterface);
dataHandler.loadConnectionData();
// Should immediately return if called again since the connectionBox will have been loaded
dataHandler.loadConnectionData();
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DatabaseLogExceptionFactoryTest method testExceptionStrategyWithPacketTooBigException.
/**
* PDI-5153
* Test that in case of PacketTooBigException exception there will be no stack trace in log
*/
@Test
public void testExceptionStrategyWithPacketTooBigException() {
DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
PacketTooBigException e = new PacketTooBigException();
when(logTable.getDatabaseMeta()).thenReturn(databaseMeta);
when(databaseMeta.getDatabaseInterface()).thenReturn(databaseInterface);
LogExceptionBehaviourInterface exceptionStrategy = DatabaseLogExceptionFactory.getExceptionStrategy(logTable, new KettleDatabaseException(e));
String strategyName = exceptionStrategy.getClass().getName();
assertEquals(SUPPRESSABLE_WITH_SHORT_MESSAGE, strategyName);
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DatabaseLogExceptionFactoryTest method testExceptionStrategyWithMysqlDataTruncationException80driver.
@Test
public void testExceptionStrategyWithMysqlDataTruncationException80driver() {
DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
com.mysql.cj.jdbc.exceptions.MysqlDataTruncation e = new com.mysql.cj.jdbc.exceptions.MysqlDataTruncation();
when(logTable.getDatabaseMeta()).thenReturn(databaseMeta);
when(databaseMeta.getDatabaseInterface()).thenReturn(databaseInterface);
LogExceptionBehaviourInterface exceptionStrategy = DatabaseLogExceptionFactory.getExceptionStrategy(logTable, new KettleDatabaseException(e));
String strategyName = exceptionStrategy.getClass().getName();
assertEquals(SUPPRESSABLE_WITH_SHORT_MESSAGE, strategyName);
}
Aggregations