use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class ValueMetaBaseTest method testGetValueFromSqlTypeNetezza.
/**
* PDI-10877 Table input step returns no data when pulling a timestamp column from IBM Netezza
*
* @throws Exception
*/
@Test
public void testGetValueFromSqlTypeNetezza() throws Exception {
ValueMetaBase obj = new ValueMetaBase();
DatabaseInterface databaseInterface = new NetezzaDatabaseMeta();
ResultSet resultSet = Mockito.mock(ResultSet.class);
ResultSetMetaData metaData = Mockito.mock(ResultSetMetaData.class);
Mockito.when(resultSet.getMetaData()).thenReturn(metaData);
Mockito.when(metaData.getColumnType(1)).thenReturn(Types.DATE);
Mockito.when(metaData.getColumnType(2)).thenReturn(Types.TIME);
obj.type = ValueMetaInterface.TYPE_DATE;
// call to testing method
obj.getValueFromResultSet(databaseInterface, resultSet, 0);
// for jdbc Date type getDate method called
Mockito.verify(resultSet, Mockito.times(1)).getDate(Mockito.anyInt());
obj.getValueFromResultSet(databaseInterface, resultSet, 1);
// for jdbc Time type getTime method called
Mockito.verify(resultSet, Mockito.times(1)).getTime(Mockito.anyInt());
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DataHandler method setConnectionSpecificInfo.
private void setConnectionSpecificInfo(DatabaseMeta meta) {
getControls();
if (databaseDialectList != null) {
databaseDialectList.setElements(databaseDialects);
DatabaseInterface databaseInterface = meta.getDatabaseInterface();
if (databaseInterface instanceof GenericDatabaseMeta) {
databaseDialectList.setSelectedItem(((GenericDatabaseMeta) databaseInterface).getDatabaseDialect());
}
}
if (hostNameBox != null) {
hostNameBox.setValue(meta.getHostname());
}
// Database name:
if (databaseNameBox != null) {
databaseNameBox.setValue(meta.getDatabaseName());
}
// Username:
if (userNameBox != null) {
userNameBox.setValue(meta.getUsername());
}
// Password:
if (passwordBox != null) {
passwordBox.setValue(meta.getPassword());
}
// Streaming result cursor:
if (resultStreamingCursorCheck != null) {
resultStreamingCursorCheck.setChecked(meta.isStreamingResults());
}
// Data tablespace:
if (dataTablespaceBox != null) {
dataTablespaceBox.setValue(meta.getDataTablespace());
}
// Index tablespace
if (indexTablespaceBox != null) {
indexTablespaceBox.setValue(meta.getIndexTablespace());
}
// Strict Number(38) interpretation
if (strictBigNumberInterpretaion != null) {
// Check if oracle
if (meta.getDatabaseInterface() instanceof OracleDatabaseMeta) {
strictBigNumberInterpretaion.setVisible(true);
strictBigNumberInterpretaion.setChecked(((OracleDatabaseMeta) meta.getDatabaseInterface()).strictBigNumberInterpretation());
} else {
strictBigNumberInterpretaion.setVisible(false);
strictBigNumberInterpretaion.setChecked(false);
}
}
if (serverInstanceBox != null) {
serverInstanceBox.setValue(meta.getSQLServerInstance());
}
// SQL Server double decimal separator
if (doubleDecimalSeparatorCheck != null) {
doubleDecimalSeparatorCheck.setChecked(meta.isUsingDoubleDecimalAsSchemaTableSeparator());
}
// SAP Attributes...
if (languageBox != null) {
languageBox.setValue(meta.getAttributes().getProperty("SAPLanguage"));
}
if (systemNumberBox != null) {
systemNumberBox.setValue(meta.getAttributes().getProperty("SAPSystemNumber"));
}
if (clientBox != null) {
clientBox.setValue(meta.getAttributes().getProperty("SAPClient"));
}
// Generic settings...
if (customUrlBox != null) {
customUrlBox.setValue(meta.getAttributes().getProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL));
}
if (customDriverClassBox != null) {
customDriverClassBox.setValue(meta.getAttributes().getProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS));
}
// Server Name: (Informix)
if (serverNameBox != null) {
serverNameBox.setValue(meta.getServername());
}
// Microsoft SQL Server Use Integrated Security
if (useIntegratedSecurityCheck != null) {
Object value = meta.getAttributes().get(MSSQLServerNativeDatabaseMeta.ATTRIBUTE_USE_INTEGRATED_SECURITY);
if (value != null && value instanceof String) {
String useIntegratedSecurity = (String) value;
useIntegratedSecurityCheck.setChecked(Boolean.parseBoolean(useIntegratedSecurity));
} else {
useIntegratedSecurityCheck.setChecked(false);
}
}
if (webAppName != null) {
// Insert default value only for new connection, allowing it to be empty in case of editing existing one
if (databaseMeta == null || Utils.isEmpty(databaseMeta.getDisplayName())) {
webAppName.setValue(DEFAULT_WEB_APPLICATION_NAME);
} else {
webAppName.setValue(meta.getDatabaseName());
}
}
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DatabaseLogExceptionFactoryTest method testExceptionStrategyWithMysqlDataTruncationException.
/**
* PDI-5153
* Test that in case of MysqlDataTruncation exception there will be no stack trace in log
*/
@Test
public void testExceptionStrategyWithMysqlDataTruncationException() {
DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
MysqlDataTruncation e = new 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);
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DatabaseLogExceptionFactoryTest method testExceptionStrategyWithMaxAllowedPacketException.
/**
* PDI-5153
* Test that in case of MaxAllowedPacketException exception there will be no stack trace in log (MariaDB)
*/
@Test
public void testExceptionStrategyWithMaxAllowedPacketException() {
DatabaseMeta databaseMeta = mock(DatabaseMeta.class);
DatabaseInterface databaseInterface = new MariaDBDatabaseMeta();
MaxAllowedPacketException e = new MaxAllowedPacketException();
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 TableOutputMetaTest method testSupportsErrorHandling.
@Test
public void testSupportsErrorHandling() throws Exception {
TableOutputMeta tableOutputMeta = new TableOutputMeta();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
tableOutputMeta.setDatabaseMeta(dbMeta);
DatabaseInterface databaseInterface = mock(DatabaseInterface.class);
when(dbMeta.getDatabaseInterface()).thenReturn(databaseInterface);
when(databaseInterface.supportsErrorHandling()).thenReturn(true, false);
assertTrue(tableOutputMeta.supportsErrorHandling());
assertFalse(tableOutputMeta.supportsErrorHandling());
tableOutputMeta.setDatabaseMeta(null);
assertTrue(tableOutputMeta.supportsErrorHandling());
}
Aggregations