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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
博乐市| 太仓市| 如皋市| 新沂市| 长治市| 襄汾县| 邻水| 南川市| 井研县| 青河县| 炉霍县| 乐东| 揭阳市| 新乡市| 肇东市| 通化市| 苏尼特左旗| 江都市| 大连市| 延长县| 来安县| 晋城| 乌兰察布市| 边坝县| 丰县| 利津县| 鹤岗市| 大洼县| 阜新| 东平县| 巴林左旗| 海林市| 桐乡市| 河北省| 临颍县| 满城县| 饶平县| 涞源县| 若羌县| 汕头市| 饶河县|