读书人

为何写不进数据库

发布时间: 2012-12-17 09:31:40 作者: rapoo

为什么写不进数据库?
Statement stm=conn.createStatement(); //创建语句对象
InetAddress inetaddress=InetAddress.getLocalHost();//返回主机名和ip的InetAddres型对象String s=inetaddress.getHostAddress(); //返回本机ip地址
int por=1111; //端口号设为1111
stm.executeUpdate("update student set state=1 where state=0");
PreparedStatement pstmt1 = conn.prepareStatement("update student set ip=? where ip=0");
pstmt1.setString(1,s);
PreparedStatement pstmt2 = conn.prepareStatement("update student set port=? where port=0");
pstmt2.setInt(1,por);
state能写入数据库,ip,port写不进数据库?下面是我建的表 conn是connection对象
列名 数据类型 值
id int 000000
paw int 000000
state int 0
ip varchar(15) 0
port int 0
[最优解释]
这代码写的..
pstmt1. executeUpdate();
pstmt2. executeUpdate();


[其他解释]
executeUpdate
你这个方法没有执行吧。
[其他解释]
该回复于2012-11-18 03:47:54被管理员删除

读书人网 >J2EE开发

热点推荐