Search in sources :

Example 16 with TJDBCConnectionProperties

use of org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties in project components by Talend.

the class JDBCConnectionTestIT method testConnection.

public void testConnection() {
    TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
    TJDBCConnectionProperties properties = DBTestUtils.createCommonJDBCConnectionProperties(allSetting, definition);
    JDBCSourceOrSink sourceOrSink = new JDBCSourceOrSink();
    sourceOrSink.initialize(null, properties);
    ValidationResult result = sourceOrSink.validate(null);
    assertTrue(result.getStatus() == ValidationResult.Result.OK);
    try (Connection conn1 = sourceOrSink.getConnection(null);
        Connection conn2 = sourceOrSink.getConnection(null)) {
        assertTrue(conn1 == conn2);
        assertTrue(!conn1.isClosed());
    } catch (ClassNotFoundException | SQLException e) {
        Assert.fail(e.getMessage());
    }
}
Also used : JDBCSourceOrSink(org.talend.components.jdbc.runtime.JDBCSourceOrSink) TJDBCConnectionProperties(org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ValidationResult(org.talend.daikon.properties.ValidationResult) TJDBCConnectionDefinition(org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionDefinition)

Aggregations

TJDBCConnectionProperties (org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties)16 Test (org.junit.Test)14 TJDBCConnectionDefinition (org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionDefinition)14 JDBCSourceOrSink (org.talend.components.jdbc.runtime.JDBCSourceOrSink)12 ValidationResult (org.talend.daikon.properties.ValidationResult)12 Connection (java.sql.Connection)7 SQLException (java.sql.SQLException)4 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 WriteOperation (org.talend.components.api.component.runtime.WriteOperation)2 JDBCCommitSourceOrSink (org.talend.components.jdbc.runtime.JDBCCommitSourceOrSink)2 JDBCRollbackSourceOrSink (org.talend.components.jdbc.runtime.JDBCRollbackSourceOrSink)2 JDBCSink (org.talend.components.jdbc.runtime.JDBCSink)2 JDBCOutputInsertWriter (org.talend.components.jdbc.runtime.writer.JDBCOutputInsertWriter)2 TJDBCCommitDefinition (org.talend.components.jdbc.tjdbccommit.TJDBCCommitDefinition)2 TJDBCCommitProperties (org.talend.components.jdbc.tjdbccommit.TJDBCCommitProperties)2 TJDBCOutputDefinition (org.talend.components.jdbc.tjdbcoutput.TJDBCOutputDefinition)2 TJDBCOutputProperties (org.talend.components.jdbc.tjdbcoutput.TJDBCOutputProperties)2 TJDBCRollbackDefinition (org.talend.components.jdbc.tjdbcrollback.TJDBCRollbackDefinition)2