# CloverETL + Postgresql

**URL:** <https://forum.cloverdx.com/t/cloveretl-postgresql/799>\
**Category:** CloverDX Platform\
**Created:** [January 17, 2011, 12:00am UTC](https://forum.cloverdx.com/t/cloveretl-postgresql/799 "2011-01-17T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsavina](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@gsavina](https://forum.cloverdx.com/u/gsavina)\
**Post date:** [January 17, 2011, 12:00am UTC](https://forum.cloverdx.com/t/cloveretl-postgresql/799/1 "2011-01-17T00:00:00Z")

</div>

Hi, I have a problem with database postgresql  
When using db\_output\_table component if query fails, all the next record fails with this error code:

current transaction is aborted, commands ignored until end of transaction block

I’ve tried to use savepoints in a custom copy of db\_output\_table but results are the same.

Can anyone help me?

I’ve tried postgres 8.3 and 9.0

Thank you.  
Giampiero.

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [January 18, 2011, 11:45am UTC](https://forum.cloverdx.com/t/cloveretl-postgresql/799/2 "2011-01-18T11:45:32Z")

</div>

Hello Giampiero,  
problem is not in DBOutputTable component, but in DefaultConnection object (see [http://bug.cloveretl.org/view.php?id=5711](http://bug.cloveretl.org/view.php?id=5711)).  
As a workaround you can write your connection object, that extends org.jetel.connection.jdbc.specific.conn.PostgreConnection. In this class you need to add the methods:

```auto

	@Override
	public void commit() throws SQLException {
		connection.commit();
	}
	
	@Override
	public void rollback() throws SQLException {
		connection.rollback();
	}
	
	@Override
	public void rollback(Savepoint savepoint) throws SQLException {
		connection.rollback(savepoint);
	}

```

To make the graph to work properly, you also need to set _atomicSQL=true_ or _commit=1_ on the DBOutputTable component to restore the transaction after the invalid record.

---

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [January 18, 2011, 3:52pm UTC](https://forum.cloverdx.com/t/cloveretl-postgresql/799/3 "2011-01-18T15:52:57Z")

</div>

To make working such connection with CloverETL, you need to create new plug-in, that contains:

- Connection extending org.jetel.connection.jdbc.specific.conn.DefaultConnection. in your case:

```auto
package com.agata.connection;  
import java.sql.SQLException;  
import java.sql.Savepoint;  
import org.jetel.connection.jdbc.DBConnection;  
import org.jetel.connection.jdbc.specific.JdbcSpecific.OperationType;  
import org.jetel.connection.jdbc.specific.conn.PostgreConnection;  
import org.jetel.exception.JetelException;  
public class MyPostgreConnection extends PostgreConnection {  
	public MyPostgreConnection(DBConnection dbConnection,  
			OperationType operationType) throws JetelException {  
		super(dbConnection, operationType);  
	}  
	@Override  
	public void commit() throws SQLException {  
		connection.commit();  
	}  
	  
	@Override  
	public void rollback() throws SQLException {  
		connection.rollback();  
	}  
	  
	@Override  
	public void rollback(Savepoint savepoint) throws SQLException {  
		connection.rollback(savepoint);  
	}  
}  

```

- JdbcSpecific extending org.jetel.connection.jdbc.specific.impl.AbstractJdbcSpecific, that creates above Connection object:

```auto
package com.agata.connection;  
import java.sql.Connection;  
import org.jetel.connection.jdbc.DBConnection;  
import org.jetel.connection.jdbc.specific.impl.PostgreSpecific;  
import org.jetel.exception.JetelException;  
public class MyPostgreJdbcSpecific extends PostgreSpecific {  
	private static final MyPostgreJdbcSpecific INSTANCE = new MyPostgreJdbcSpecific();  
	  
	public static MyPostgreJdbcSpecific getInstance() {  
		return INSTANCE;  
	}  
	/* (non-Javadoc)  
	 * @see org.jetel.connection.jdbc.specific.impl.AbstractJdbcSpecific#createSQLConnection(org.jetel.connection.jdbc.DBConnection, org.jetel.connection.jdbc.specific.JdbcSpecific.OperationType)  
	 */  
	@Override  
	public Connection createSQLConnection(DBConnection connection, OperationType operationType) throws JetelException {  
		return new MyPostgreConnection(connection, operationType);  
	}  
}  

```

- and _plugin.xml_, that informs CloverETL about the above object:

```auto
<plugin  
	id="com.agata.connection"  
	version="0.0.0.devel"  
	provider-name="Javlin a.s.">  
	<runtime>  
		<library path="connection.jar"/>  
   	</runtime>  
	<requires engine-version="3.0">  
		<import plugin-id="org.jetel.connection"/>  
		<import plugin-id="org.jetel.jdbc"/>  
	</requires>  
	<extension point-id="jdbcSpecific">  
		<parameter id="database" value="MY_POSTGRE"/>  
		<parameter id="name" value="MyPostgreSQL"/>  
		<!--parameter id="majorVersion" value="x"/-->  
		<parameter id="class" value="com.agata.connection.MyPostgreJdbcSpecific"/>  
	</extension>  
	<extension point-id="jdbcDriver">  
		<parameter id="database" value="MY_POSTGRE"/>  
		<parameter id="name" value="MyPostgreSQL"/>  
		<parameter id="dbDriver" value="org.postgresql.Driver"/>  
		<parameter id="driverLibrary" value="../org.jetel.jdbc/lib/postgre/postgresql-8.3-603.jdbc3.jar"/>  
		<parameter id="urlHint" value="jdbc:postgresql://hostname/database"/>  
		<parameter id="jdbcSpecific" value="MY_POSTGRE"/>  
	</extension>  
</plugin>  

```

The java files should be packed to the connection.jar file and placed with the _plugin.xml_ to other CloverETL plug-ins (something like "c:\Program  
Files\eclipse\plugins\com.cloveretl.gui\_3.0.1\lib\plugins\) in theirs own folder.
