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();
}
}