返回信息流public void insertStudent(){
for(int i=0;i<6;i++){//声明文本框输入信息
str1[i]=jtxtArray[i].getText().trim();
}
if(str1[0].equals("")||str1[1].equals("")||str1[2].equals("")
||str1[3].equals("")||str1[4].equals("")||str1[5].equals(""))
{//当各文本框为空提示
JOptionPane.showMessageDialog(this, "学生信息不能为空!!!",
"消息",JOptionPane.INFORMATION_MESSAGE);
return;
}
if(!str1[0].equals("")&&!str1[1].equals("")&&!str1[2].equals("")
&&!str1[3].equals("")&&!str1[4].equals("")&&!str1[5].equals(""))
{//当在文本框输入信息
sql="insert into 用户信息表(学号,姓名,性别,班级,学院,密码) values('"+str1[0]+"','"+str1[1]+"','"
+ str1[2] + "',' "+str1[3]+"',' "+str1[4]+"','"+str1[5]+"')";
db=new DataBase();
db.updateDb(sql);//修改用户信息表
Vector<String> v = new Vector<String>();
for(int i=0;i<=5;i++){//将每列添加到临时数组v
v.add(str1[i]);
if(i<6){jtxtArray[i].setText("");}
}
data.add(v);
dtm.setDataVector(data,head);//更新table并显示
jt.updateUI();
jt.repaint();
return;
}
}
public int updateDb(String sql){//声明update方法
try{
sql = new String(sql.getBytes(),"ISO-8859-1");//转码
count=stat.executeUpdate(sql);
}
catch(Exception ie){ie.printStackTrace();}
return count;
}
能够执行,但是数据库没有一点修改,这是为何
这是一条镜像帖。来源:北邮人论坛 / java / #14662同步于 2010/5/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
大牛请看
koone
2010/5/25镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
【 在 koone 的大作中提到: 】
: public void insertStudent(){
: for(int i=0;i<6;i++){//声明文本框输入信息
: str1[i]=jtxtArray[i].getText().trim();
: ...................
有没有commit?
【 在 koone 的大作中提到: 】
: public void insertStudent(){
: for(int i=0;i<6;i++){//声明文本框输入信息
: str1[i]=jtxtArray[i].getText().trim();
: ...................