Search in sources :

Example 61 with Savepoint

use of java.sql.Savepoint in project opentheso by miledrousset.

the class RelationsHelper method setRelationMT.

/**
 * Cette fonction permet d'ajouter une relation MT ou domaine à un concept
 *
 * @param conn
 * @param idConcept
 * @param idGroup
 * @param idThesaurus
 * @return boolean
 */
public boolean setRelationMT(Connection conn, String idConcept, String idGroup, String idThesaurus) {
    Statement stmt;
    boolean status = false;
    String query;
    Savepoint savepoint = null;
    try {
        // Get connection from pool
        savepoint = conn.setSavepoint();
        try {
            stmt = conn.createStatement();
            try {
                /*    if (!new RelationsHelper().addRelationHistorique(conn, idConcept, idThesaurus, idConcept, "TT", idUser, "DEL")) {
                        return false;
                    }*/
                query = "UPDATE concept_group_concept set" + " idgroup = '" + idGroup + "'" + " WHERE idconcept ='" + idConcept + "'" + " AND idthesaurus = '" + idThesaurus + "'";
                stmt.executeUpdate(query);
                status = true;
            } finally {
                stmt.close();
            }
        } finally {
        // conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        if (sqle.getSQLState().equalsIgnoreCase("23505")) {
            try {
                if (savepoint != null) {
                    conn.rollback(savepoint);
                    status = true;
                }
            } catch (SQLException ex) {
                Logger.getLogger(RelationsHelper.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            log.error("Error while deleting relation Group for Concept : " + idConcept, sqle);
        }
    }
    return status;
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Savepoint(java.sql.Savepoint)

Example 62 with Savepoint

use of java.sql.Savepoint in project spanner-jdbc by olavloite.

the class AbstractCloudSpannerConnectionTest method testRollback.

@Test
public void testRollback() throws Exception {
    thrown.expect(SQLFeatureNotSupportedException.class);
    AbstractCloudSpannerConnection testSubject;
    Savepoint savepoint = null;
    // default test
    testSubject = createTestSubject();
    testSubject.rollback(savepoint);
}
Also used : Savepoint(java.sql.Savepoint) Test(org.junit.Test)

Aggregations

Savepoint (java.sql.Savepoint)62 SQLException (java.sql.SQLException)20 Statement (java.sql.Statement)20 Connection (java.sql.Connection)17 ResultSet (java.sql.ResultSet)13 Vector (java.util.Vector)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 DatabaseMetaData (java.sql.DatabaseMetaData)6 PreparedStatement (java.sql.PreparedStatement)6 TransactionStatus (org.springframework.transaction.TransactionStatus)6 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)6 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)6 SQLClientInfoException (java.sql.SQLClientInfoException)5 HashMap (java.util.HashMap)5 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)2 CommandInterface (com.wplatform.ddal.command.CommandInterface)2 DbException (com.wplatform.ddal.message.DbException)2