不成功有没有错误的,有错误才好定位问题,发一下?
你可以在这串代码了打印一行字,看代码有没有执行到这里来
用 int a=st.executeupdate(sql)来接收一下,打印a看是否为0,如果为0就是这个sql没有执行。
不行的话使用一下这个
Connection conn=BaseConnection .getConnection();
PreparedStatement ps=null;
String sql=""//sql语句
try{
ps= conn.prepareStatement(sql);//把写好的sql语句传递到数据库
int a=ps.executeUpdate();//这个方法用于改变数据库数据,a代表改变数据库的条数
if(a>0){
System.out.println("添加成功");
}else{
System.out.println("添加失败");
}
}catch(Exception e){
e.printStackTrace();
}
这个你应该commit一下