简体   繁体   English

Firebird提交在Java应用程序中不起作用

[英]Firebird commit doesn't work in Java Application

I'm using a procedure to insert data in my firebird database. 我正在使用一个过程在我的firebird数据库中插入数据。 This procedure is called in a while command because there is no limit for how many items I can insert, for example: 在while命令中调用此过程,因为我可以插入的项目数没有限制,例如:

while (there's itens) {
    query("select * from procedure_insert(id,desc,etc);");
}

This doesn't work, after I finish my insertion not a single item is inserted in the database. 这不起作用,在我完成插入后,没有在数据库中插入单个项目。 My procedure works fine there's no doubt, I believe it's a problem with the class I use to query and commit 我的程序运行正常毫无疑问,我相信这是我用来查询和提交的类的问题

Here is my code: 这是我的代码:

Persistence class: 持久性等级:

public class Persistence {

    public static Connection con = Conn.getConn();
    public static Statement stm  = null;

    public static void Conn(){
        try {
            stm  = con.createStatement();
        } catch (SQLException e) {
            //
        }
    }

    public static void Insert(String query) {

        try {
            stm.execute(query);
        } catch (SQLException e) {
            //
        } 
    }

    public static void Commit(){
        try {
            con.commit();
    } catch (SQLException e) {
        //
    }
}

Insert: 插入:

while(rs.next()){

    Items item = new Items();
    item.setItem_data(rs.getString("ZPED_ITEM_DATA"));
    item.setItem_desconto(rs.getDouble("ZPED_ITEM_VALOR_V") - rs.getDouble("ZPED_ITEM_DESCONTO"));
    item.setItem_produto(rs.getInt("ZPED_ITEM_PRODUTO"));
    item.setItem_qtd(rs.getDouble("ZPED_ITEM_QTD"));
    item.setItem_valor_v(rs.getDouble("ZPED_ITEM_VALOR_V"));
    item.setPed_cod(rs.getInt("ZPED_COD"));
    ////////////////////////////////////////////////////////////////
    Persistence.Insert("SELECT * FROM PEDIDOS_PROC("+a+","+b+","+p.get(0).getCod_n()+",'"+p.get(0).getData()+"',55,"+item.getItem_produto()+",0,"+item.getItem_qtd()+","+item.getItem_valor_v()+",'A',2);");
    Persistence.Commit();
}

thank you! 谢谢!

I'm using JDBC Jaybird Full 2.2.7 我正在使用JDBC Jaybird Full 2.2.7

is PEDIDOS_PROC selectable procedure? 是PEDIDOS_PROC可选程序吗? If no you must to execute it 如果不是,你必须执行它

execute procedure PEDIDOS_PROC(params...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM