国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

分享到微博請遵守國家法律
田东县| 松江区| 安图县| 广宁县| 民乐县| 琼海市| 东源县| 海原县| 丰城市| 宜春市| 辽宁省| 海安县| 隆昌县| 宜君县| 迭部县| 芦溪县| 墨玉县| 宾川县| 丹东市| 偏关县| 抚顺市| 西乌| 淳安县| 巴南区| 清远市| 如皋市| 福建省| 阿荣旗| 温宿县| 常熟市| 伊通| 县级市| 田阳县| 朔州市| 永平县| 读书| 阳春市| 定结县| 杨浦区| 赤壁市| 徐水县|