jdbc初学 之删除表中数据

pattaya2008 2006-12-15 11:59:59
import java.sql.*;
public class JdbcOdbc {
public static void main(String[] args)
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection ("jdbc:odbc:test","sa","sa");
Statement stmt=con.createStatement();
stmt.executeUpdate("delete stulnfo values('赵惠',28,10,2,'上海市')");//应该怎么写才对??
ResultSet rs=stmt.executeQuery("select * from stulnfo");

while(rs.next())
{
System.out.println(rs.getString(1)+" "+rs.getString(2) +" "+rs.getString(3)+" "+rs.getString(4));

}
rs.close();
stmt.close();
}catch(Exception e)
{
e.printStackTrace();
}
}
}
删除表中的一行数据怎么样删除,我的那句删除语句不对吗??
应该怎么写
谢谢!
...全文
139 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandflying 2006-12-15
  • 打赏
  • 举报
回复
嘿嘿,没问题的话节个帖吧
pattaya2008 2006-12-15
  • 打赏
  • 举报
回复
好的,谢谢!
sandflying 2006-12-15
  • 打赏
  • 举报
回复
Delete from yourtable where name='赵惠' and 列名=28 and 列名=10 ……
最好是用主键,直接一个where 主键=值 就可以了

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧