最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

SQL

2023-06-30 10:08 作者:天塵灬厭宇  | 我要投稿

package com.conn; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.openmbean.OpenMBeanAttributeInfoSupport; public class SqlTest { public void ins_shop(shops shop) throws SQLException { String sqlString="insert into tb_goods values("+shop.getGoodId()+","+'"'+shop.getGoodName()+'"'+","+shop.getNum()+","+shop.getPrice()+")"; Connection conn =JBconnection.getcon(); PreparedStatement ps =conn.prepareStatement(sqlString); int rSet= ps.executeUpdate(); } public void delete_shop(int id) throws SQLException { String sqlString="delete from tb_goods where goodId="+id; Connection conn =JBconnection.getcon(); PreparedStatement ps =conn.prepareStatement(sqlString); int rSet= ps.executeUpdate(); JBconnection.close(null, ps, conn); } public static ArrayList query() throws SQLException { String sqlString="select * from tb_goods "; Connection conn =JBconnection.getcon(); PreparedStatement ps =conn.prepareStatement(sqlString); ResultSet rSet= ps.executeQuery(); ArrayList stus=new ArrayList<>(); while (rSet.next()) { int id=rSet.getInt("goodId"); String name=rSet.getString("goodName"); int num=rSet.getInt("num"); Double price=rSet.getDouble("price"); shops stu= new shops(id, name, num, price); stus.add(stu); } JBconnection.close(rSet, ps, conn); return stus; } public static void main(String[] args) throws SQLException { SqlTest sqlTest=new SqlTest(); ArrayList all = sqlTest.query(); Object[][] data=new Object[all.size()][4]; for (int i = 0; i < all.size(); i++) { data[i][0]=all.get(i).getGoodId(); data[i][1]=1; } shops shops=new shops(20, "小米", 10, 4000); try { sqlTest.ins_shop(shops); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }

SQL的評論 (共 條)

分享到微博請遵守國家法律
淳化县| 营山县| 兴海县| 新竹县| 五寨县| 双峰县| 桐柏县| 永兴县| 普宁市| 甘洛县| 大邑县| 荔浦县| 浏阳市| 蓬莱市| 改则县| 礼泉县| 涡阳县| 扶绥县| 赤壁市| 繁昌县| 墨江| 安顺市| 通许县| 延寿县| 寿阳县| 马鞍山市| 桦甸市| 合作市| 全南县| 克拉玛依市| 横峰县| 关岭| 竹山县| 新巴尔虎右旗| 射阳县| 左贡县| 和龙市| 渭南市| 克拉玛依市| 白玉县| 怀柔区|