You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Olivier Voutat <ol...@yahoo.com.br> on 2006/09/29 21:30:38 UTC

Commons DbUtils - insert, update and delete commands

Anyone knows a way to execute a insert, update or delete command using Commons DbUtils and just passing the object ? Or the best feature is to convert the resultset in a list of objects ?

Using SqlStrings is not much simplier than using PreparedStatement

public static void updateteste() {
        try {
            ConexaoSql.getInstance();
            prepstatement = 
                conexao.prepareStatement(
                        "UPDATE usuario SET NOME = ? WHERE LOGIN = ?;");
            prepstatement.setString(1,"Teste");
            prepstatement.setString(2,"afre");
            prepstatement.executeUpdate();
        } catch (SQLException e) {e.printStackTrace();}
        destroy();
    }
 
Olivier Jeanpierre Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917




		
_______________________________________________________ 
O Yahoo! está de cara nova. Venha conferir! 
http://br.yahoo.com

Commons DbUtils - insert, update and delete commands

Posted by li...@yahoo.com.br.
Anyone knows a way to execute a insert, update or delete command using Commons DbUtils and just passing the object ? Or the best feature is to convert the resultset in a list of objects ?

Using SqlStrings is not much simplier than using PreparedStatement

public static void updateteste() {
        try {
            ConexaoSql.getInstance();
            prepstatement = 
                conexao.prepareStatement(
                        "UPDATE usuario SET NOME = ? WHERE LOGIN = ?;");
            prepstatement.setString(1,"Teste");
            prepstatement.setString(2,"afre");
            prepstatement.executeUpdate();
        } catch (SQLException e) {e.printStackTrace();}
        destroy();
    }
 
Olivier Jeanpierre Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917


 		
---------------------------------
 Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora!