title: Continue Postgres transaction with exceptions in Java
body: <p>The <strong>insert</strong> method below insert links on a table in the database (PostgreSQL), but if a error occurs, the rest of transaction is affected and dont works. The exception is because the field URL is unique.</p>
  
  <p>It's possible in PostgreSQL continue the transaction even with the exceptions?</p>
  
  <pre><code>for (int i = 0, n = page.getLinks().length; i &lt; n; i++) {
       linkBD.insert(page.getLink(i), idPage);
  }            
  
  public boolean insert(Link link, int idPage) {
      try {
          String sql = "INSERT INTO link (id,idPage,url,linkText,"
          + "visited,broken) VALUES(nextval('idLinkSqc'),?,?,?,?,?)";
  
          PreparedStatement pstm = Conn.conn.prepareStatement(sql);
  
          pstm.setInt(1, idPage);
          pstm.setString(2, link.getUrl());
          pstm.setString(3, link.getLinkText());
          pstm.setBoolean(4, false);
          pstm.setBoolean(5, false);
  
          pstm.execute();            
          Conn.commit();
          pstm.close();            
          return true;
      } catch (Exception e) {
          System.out.println("Erro inserindo link no banco de dados: " + e.getMessage());
          System.out.println("Erro no link: "+link.getUrl());
          return false;
      }
  }
  </code></pre>
  
  <p>The <strong>error message</strong> in portuguese: transação atual foi interrompida, comandos ignorados até o fim do bloco de transação</p>
  
  <p>The translation of Google Translate, I think is right: <strong><em>current transaction is aborted, commands ignored until end of transaction block</em></strong></p>