标题:java连接Access时的提交问题??
取消只看楼主
luyihuaa5201
Rank: 2
等 级:论坛游民
帖 子:254
专家分:10
注 册:2007-3-25
结帖率:66.67%
 问题点数:0 回复次数:0 
java连接Access时的提交问题??
我写了程序,先往Access中插入一条数据,然后在查询数据。但插入成功了,就是查询不出来,我知道是插入后没有提交,请问Access操作后怎么提交??以下是我的代码:请问该怎么加哈???
    package test;

public class Dao {
   
    public int  insert(Bean user){
        int flag = 0 ;
        ContinueAccess access = new ContinueAccess();
        String sql = "insert into t_user values ('"+user.getId()+"','"+user.getName()+"')" ;
        System.out.println(sql);
        try {
            flag = access.update(sql);
        } catch (Exception e) {
            // TODO: handle exception
        }    finally{
            
            access.close();
        }
        return flag ;
    }
    public int find(){
        int flag = 0 ;
        ContinueAccess access = new ContinueAccess();
        String sql = "select * from t_user " ;
        System.out.println(sql);
        
        try {
            flag = access.update(sql);
        } catch (Exception e) {
            // TODO: handle exception
        }    finally{
            access.close();
        }
        return flag ;
    }
    public static void main(String[] args) {
        
        Bean user = new Bean();
        user.setId("004");
        user.setName("黄盛");
        Dao dao = new Dao();
        dao.insert(user);
        dao.find();
    }

}
搜索更多相关主题的帖子: java Access user insert 
2008-03-21 13:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-204536-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055640 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved