当前位置: 首页 > news >正文

温州营销推广公司台州seo网站排名优化

温州营销推广公司,台州seo网站排名优化,wordpress设置权限设置,.net网站程序抽取执行更新方法抽取查询方法 —— ResultSetMetaData ResultSetMetaData rsmd rs.getMetaData();//元数据,结果集的结构数据 抽取查询方法 —— 解析结果集封装成实体对象提取 获取连接 和 释放资源 的方法将数据库配置信息转移到配置文件 dependenciesdepend… 抽取执行更新方法抽取查询方法 —— ResultSetMetaData   ResultSetMetaData rsmd rs.getMetaData();//元数据,结果集的结构数据 抽取查询方法 —— 解析结果集封装成实体对象提取 获取连接 和 释放资源 的方法将数据库配置信息转移到配置文件 dependenciesdependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.10/version/dependencydependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.12/versionscopetest/scope/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion8.0.28/version/dependency/dependencies package com.csdn.fruit.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; Data NoArgsConstructor AllArgsConstructor public class Fruit implements Serializable {private Integer fid;private String fname;private Integer price;private Integer fcount;private String remark;public Fruit(String fname, Integer price, Integer fcount, String remark) {this.fname fname;this.price price;this.fcount fcount;this.remark remark;}Overridepublic String toString() {return fname \t\t price \t\t fcount \t\t remark;} }jdbc.drivercom.mysql.cj.jdbc.Driver jdbc.urljdbc:mysql:///fruitdb jdbc.userroot jdbc.pwd123456 package com.csdn.mymvc.dao; import com.csdn.mymvc.util.ClassUtil; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Properties; public abstract class BaseDaoT {private String DRIVER;private String URL;private String USER;private String PWD;private String entityClassName;public BaseDao() {// this 是谁 this代表的是 FruitDaoImpl 的实例对象因为 BaseDao是抽象类不能直接创建对象所以 new 的是它的子类对象 FruitDaoImpl// this.getClass() 获取的是 FruitDaoImpl 的Class对象// getGenericSuperclass() 获取到的是BaseDaoFruit// Type 是顶层接口表示所有的类型。它有一个子接口ParameterizedTypeParameterizedType genericSuperclass (ParameterizedType) this.getClass().getGenericSuperclass();// Actual:实际的// getActualTypeArguments() 获取实际的类型参数Type[] actualTypeArguments genericSuperclass.getActualTypeArguments();Type actualTypeArgument actualTypeArguments[0];// System.out.println(actualTypeArgument.getTypeName());//com.csdn.fruit.pojo.FruitentityClassName actualTypeArgument.getTypeName();loadJdbcProperties();}//加载jdbc.properties文件private void loadJdbcProperties() {try {InputStream inputStream getClass().getClassLoader().getResourceAsStream(jdbc.properties);Properties properties new Properties();properties.load(inputStream);DRIVER properties.getProperty(jdbc.driver, com.mysql.cj.jdbc.Driver);URL properties.getProperty(jdbc.url, jdbc:mysql:///fruitdb);USER properties.getProperty(jdbc.user, root);PWD properties.getProperty(jdbc.pwd, 123456);} catch (IOException e) {throw new RuntimeException(e);}}private Connection getConn() {try {Class.forName(DRIVER);return DriverManager.getConnection(URL, USER, PWD);} catch (ClassNotFoundException | SQLException e) {throw new RuntimeException(e);}}private void close(Connection conn, PreparedStatement psmt, ResultSet rs) {try {if (rs ! null) {rs.close();}if (psmt ! null) {psmt.close();}if (conn ! null !conn.isClosed()) {conn.close();}} catch (SQLException e) {throw new RuntimeException(e);}}//抽取执行更新方法//执行更新返回影响行数protected int executeUpdate(String sql, Object... params) {PreparedStatement psmt null;Connection conn null;try {conn getConn();psmt conn.prepareStatement(sql);setParams(psmt, params);return psmt.executeUpdate();} catch (SQLException e) {throw new RuntimeException(e);} finally {close(conn, psmt, null);}}//设置参数private void setParams(PreparedStatement psmt, Object... params) throws SQLException {if (params ! null params.length 0) {for (int i 0; i params.length; i) {psmt.setObject(i 1, params[i]);}}}//执行查询返回集合protected ListT executeQuery(String sql, Object... params) {ListT list new ArrayList();Connection conn null;PreparedStatement psmt null;ResultSet rs null;try {conn getConn();psmt conn.prepareStatement(sql);setParams(psmt, params);rs psmt.executeQuery();ResultSetMetaData rsmd rs.getMetaData();//元数据,结果集的结构数据while (rs.next()) {//T t new T(); T仅仅是一个符号所以不能 newT t (T) ClassUtil.createInstance(entityClassName);int columnCount rsmd.getColumnCount();//获取结果集的列的数据//jdbc中都是从 1 开始所以要把 i 改成 从 1 开始for (int i 1; i columnCount; i) {//假设循环 5 次得到 5 个值应该对应的是一个对象的 5 个属性的值String columnName rsmd.getColumnLabel(i);Object columnValue rs.getObject(i);//给 t 这个对象的 columnName 属性赋 columnValue 值ClassUtil.setProperty(t, columnName, columnValue);}list.add(t);}return list;} catch (SQLException e) {throw new RuntimeException(e);} finally {close(conn, psmt, rs);}}protected T load(String sql, Object... params) {Connection conn null;PreparedStatement psmt null;ResultSet rs null;try {conn getConn();psmt conn.prepareStatement(sql);setParams(psmt, params);rs psmt.executeQuery();ResultSetMetaData rsmd rs.getMetaData();//元数据,结果集的结构数据if (rs.next()) {//T t new T(); T仅仅是一个符号所以不能 newT t (T) ClassUtil.createInstance(entityClassName);int columnCount rsmd.getColumnCount();//获取结果集的列的数据//jdbc中都是从 1 开始所以要把 i 改成 从 1 开始for (int i 1; i columnCount; i) {//假设循环 5 次得到 5 个值应该对应的是一个对象的 5 个属性的值String columnName rsmd.getColumnLabel(i);Object columnValue rs.getObject(i);//给 t 这个对象的 columnName 属性赋 columnValue 值ClassUtil.setProperty(t, columnName, columnValue);}return t;}} catch (SQLException e) {throw new RuntimeException(e);} finally {close(conn, psmt, rs);}return null;} }package com.csdn.mymvc.util; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; public class ClassUtil {public static Object createInstance(String entityClassName) {try {return Class.forName(entityClassName).getDeclaredConstructor().newInstance();} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException |ClassNotFoundException e) {throw new RuntimeException(e);}}public static void setProperty(Object instance, String propertyName, Object propertyValue) {Class? aClass instance.getClass();try {Field field aClass.getDeclaredField(propertyName);field.setAccessible(true);field.set(instance, propertyValue);} catch (NoSuchFieldException | IllegalAccessException e) {throw new RuntimeException(e);}} }package com.csdn.fruit.dao; import com.csdn.fruit.pojo.Fruit; import java.util.List; //dao Data Access Object 数据访问对象 //接口设计 public interface FruitDao {void addFruit(Fruit fruit);void delFruit(String fname);void updateFruit(Fruit fruit);ListFruit getFruitList();Fruit getFruitByFname(String fname); }package com.csdn.fruit.dao.impl; import com.csdn.fruit.dao.FruitDao; import com.csdn.fruit.pojo.Fruit; import com.csdn.mymvc.dao.BaseDao; import java.util.List; public class FruitDaoImpl extends BaseDaoFruit implements FruitDao {Overridepublic void addFruit(Fruit fruit) {String sql insert into t_fruit values (0,?,?,?,?);super.executeUpdate(sql, fruit.getFname(), fruit.getPrice(), fruit.getFcount(), fruit.getRemark());}Overridepublic void delFruit(String fname) {String sql delete from t_fruit where fname?;super.executeUpdate(sql, fname);}Overridepublic void updateFruit(Fruit fruit) {String sql update t_fruit set fcount? where fname ?;super.executeUpdate(sql, fruit.getFcount(), fruit.getFname());}Overridepublic ListFruit getFruitList() {return super.executeQuery(select * from t_fruit);}Overridepublic Fruit getFruitByFname(String fname) {return load(select * from t_fruit where fname ?, fname);} }package com.csdn.fruit.view; import com.csdn.fruit.dao.FruitDao; import com.csdn.fruit.dao.impl.FruitDaoImpl; import com.csdn.fruit.pojo.Fruit; import java.util.List; import java.util.Scanner; public class Menu {Scanner input new Scanner(System.in);private FruitDao fruitDao new FruitDaoImpl();//显示主菜单public int showMainMenu() {System.out.println(欢迎使用水果库存系统);System.out.println(1.显示库存列表);System.out.println(2.添加库存记录);System.out.println(3.查看特定库存);System.out.println(4.水果下架);System.out.println(5.退出);System.out.println();System.out.print(请选择);return input.nextInt();}//显示库存列表public void showFruitList() {ListFruit fruitList fruitDao.getFruitList();System.out.println(----------------------------------------------------);System.out.println(名称\t\t单价\t\t库存\t\t备注);if (fruitList null || fruitList.size() 0) {System.out.println(对不起库存为空);} else {/* fruitList.forEach(new ConsumerFruit() {Overridepublic void accept(Fruit fruit) {System.out.println(fruit);}});*/// fruitList.forEach(fruit - System.out.println(fruit));fruitList.forEach(System.out::println);}System.out.println(----------------------------------------------------);}//添加库存记录public void addFruit() {System.out.print(请输入水果名称);String fname input.next();Fruit fruit fruitDao.getFruitByFname(fname);if (fruit null) {System.out.print(请输入水果单价);Integer price input.nextInt();System.out.print(请输入水果库存);Integer fcount input.nextInt();System.out.print(请输入水果备注);String remark input.next();fruit new Fruit(fname, price, fcount, remark);fruitDao.addFruit(fruit);} else {System.out.print(请输入追加的库存量);Integer fcount input.nextInt();fruit.setFcount(fruit.getFcount() fcount);fruitDao.updateFruit(fruit);}System.out.println(添加成功);}//查看特定库存记录public void showFruitInfo() {System.out.print(请输入水果名称);String fname input.next();Fruit fruit fruitDao.getFruitByFname(fname);if (fruit null) {System.out.println(对不起没有找到对应的库存记录);} else {System.out.println(----------------------------------------------------);System.out.println(名称\t\t单价\t\t库存\t\t备注);System.out.println(fruit);System.out.println(----------------------------------------------------);}}//水果下架public void delFruit() {System.out.print(请输入水果名称);String fname input.next();Fruit fruit fruitDao.getFruitByFname(fname);if (fruit null) {System.out.println(对不起没有找到需要下架的库存记录);} else {System.out.print(是否确认下架?Y/N);String confirm input.next();if (y.equalsIgnoreCase(confirm)) {fruitDao.delFruit(fname);}}}//退出public boolean exit() {System.out.print(是否确认退出Y/N);String confirm input.next();boolean flag !y.equalsIgnoreCase(confirm);return flag;} }package com.csdn.fruit.view; public class Client {public static void main(String[] args) {Menu m new Menu();boolean flag true;while (flag) {int slt m.showMainMenu();switch (slt) {case 1:m.showFruitList();break;case 2:m.addFruit();break;case 3:m.showFruitInfo();break;case 4:m.delFruit();break;case 5://方法设计时是否需要返回值依据是是否在调用的地方需要留下一些值用于再运算flag m.exit();break;default:System.out.println(你不按套路出牌);break;}}System.out.println(谢谢使用再见);} }package com.csdn.dao.impl; import com.csdn.fruit.dao.FruitDao; import com.csdn.fruit.dao.impl.FruitDaoImpl; import com.csdn.fruit.pojo.Fruit; import org.junit.Test; import java.util.List; public class FruitDaoImplTest {private FruitDao fruitDao new FruitDaoImpl();Testpublic void testAddFruit() {Fruit fruit new Fruit(香蕉, 7, 77, 波罗蜜是一种神奇的水果);fruitDao.addFruit(fruit);}Testpublic void testDelFruit() {fruitDao.delFruit(哈密瓜);}Testpublic void testUpdateFruit() {Fruit fruit new Fruit(波罗蜜, 5, 1000, 好吃);fruitDao.updateFruit(fruit);}Testpublic void testGetFruitList() {ListFruit fruitList fruitDao.getFruitList();fruitList.stream().forEach(System.out::println);}Testpublic void testGetFruitByFname() {Fruit fruit fruitDao.getFruitByFname(波罗蜜);System.out.println(fruit);}/*// this 是谁 this代表的是 FruitDaoImpl 的实例对象因为 BaseDao是抽象类不能直接创建对象所以 new 的是它的子类对象 FruitDaoImpl// this.getClass() 获取的是 FruitDaoImpl 的Class对象// getGenericSuperclass() 获取到的是BaseDaoFruit// Type 是顶层接口表示所有的类型。它有一个子接口ParameterizedTypeParameterizedType genericSuperclass (ParameterizedType) this.getClass().getGenericSuperclass();// Actual:实际的// getActualTypeArguments() 获取实际的类型参数Type[] actualTypeArguments genericSuperclass.getActualTypeArguments();Type actualTypeArgument actualTypeArguments[0];// System.out.println(actualTypeArgument.getTypeName());//com.csdn.fruit.pojo.FruitentityClassName actualTypeArgument.getTypeName();loadJdbcProperties(); */Testpublic void testActualTypeArgument() {//这个方法是用来测试 actualTypeArgument 实际返回的参数} }
文章转载自:
http://www.morning.nuobeiergw.cn.gov.cn.nuobeiergw.cn
http://www.morning.mhnb.cn.gov.cn.mhnb.cn
http://www.morning.nsrtvu.com.gov.cn.nsrtvu.com
http://www.morning.gzxnj.cn.gov.cn.gzxnj.cn
http://www.morning.cwgfq.cn.gov.cn.cwgfq.cn
http://www.morning.xpzrx.cn.gov.cn.xpzrx.cn
http://www.morning.rjmb.cn.gov.cn.rjmb.cn
http://www.morning.mnqg.cn.gov.cn.mnqg.cn
http://www.morning.gediba.com.gov.cn.gediba.com
http://www.morning.tjndb.cn.gov.cn.tjndb.cn
http://www.morning.rhmpk.cn.gov.cn.rhmpk.cn
http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com
http://www.morning.epeij.cn.gov.cn.epeij.cn
http://www.morning.wbnsf.cn.gov.cn.wbnsf.cn
http://www.morning.ffwrq.cn.gov.cn.ffwrq.cn
http://www.morning.easiuse.com.gov.cn.easiuse.com
http://www.morning.ldwxj.cn.gov.cn.ldwxj.cn
http://www.morning.jbpodhb.cn.gov.cn.jbpodhb.cn
http://www.morning.xxwhz.cn.gov.cn.xxwhz.cn
http://www.morning.qbrdg.cn.gov.cn.qbrdg.cn
http://www.morning.wjlnz.cn.gov.cn.wjlnz.cn
http://www.morning.ztdlp.cn.gov.cn.ztdlp.cn
http://www.morning.httpm.cn.gov.cn.httpm.cn
http://www.morning.tqxtx.cn.gov.cn.tqxtx.cn
http://www.morning.knmby.cn.gov.cn.knmby.cn
http://www.morning.qjzgj.cn.gov.cn.qjzgj.cn
http://www.morning.clbgy.cn.gov.cn.clbgy.cn
http://www.morning.xq3nk42mvv.cn.gov.cn.xq3nk42mvv.cn
http://www.morning.wskn.cn.gov.cn.wskn.cn
http://www.morning.znnsk.cn.gov.cn.znnsk.cn
http://www.morning.lpppg.cn.gov.cn.lpppg.cn
http://www.morning.rlhjg.cn.gov.cn.rlhjg.cn
http://www.morning.knqck.cn.gov.cn.knqck.cn
http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com
http://www.morning.jcwt.cn.gov.cn.jcwt.cn
http://www.morning.wspyb.cn.gov.cn.wspyb.cn
http://www.morning.rmltt.cn.gov.cn.rmltt.cn
http://www.morning.c7625.cn.gov.cn.c7625.cn
http://www.morning.nykzl.cn.gov.cn.nykzl.cn
http://www.morning.qzdxy.cn.gov.cn.qzdxy.cn
http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn
http://www.morning.yrflh.cn.gov.cn.yrflh.cn
http://www.morning.llgpk.cn.gov.cn.llgpk.cn
http://www.morning.lnbcx.cn.gov.cn.lnbcx.cn
http://www.morning.mtgnd.cn.gov.cn.mtgnd.cn
http://www.morning.pwgzh.cn.gov.cn.pwgzh.cn
http://www.morning.crqpl.cn.gov.cn.crqpl.cn
http://www.morning.wlbwp.cn.gov.cn.wlbwp.cn
http://www.morning.ahlart.com.gov.cn.ahlart.com
http://www.morning.rhlhk.cn.gov.cn.rhlhk.cn
http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn
http://www.morning.cwyrp.cn.gov.cn.cwyrp.cn
http://www.morning.nkyc.cn.gov.cn.nkyc.cn
http://www.morning.yxshp.cn.gov.cn.yxshp.cn
http://www.morning.rythy.cn.gov.cn.rythy.cn
http://www.morning.ftznb.cn.gov.cn.ftznb.cn
http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn
http://www.morning.inheatherskitchen.com.gov.cn.inheatherskitchen.com
http://www.morning.kqpsj.cn.gov.cn.kqpsj.cn
http://www.morning.tnwwl.cn.gov.cn.tnwwl.cn
http://www.morning.qwfq.cn.gov.cn.qwfq.cn
http://www.morning.yrkdq.cn.gov.cn.yrkdq.cn
http://www.morning.nwbnt.cn.gov.cn.nwbnt.cn
http://www.morning.kcypc.cn.gov.cn.kcypc.cn
http://www.morning.cpktd.cn.gov.cn.cpktd.cn
http://www.morning.hjjfp.cn.gov.cn.hjjfp.cn
http://www.morning.stbfy.cn.gov.cn.stbfy.cn
http://www.morning.gppqf.cn.gov.cn.gppqf.cn
http://www.morning.zwpzy.cn.gov.cn.zwpzy.cn
http://www.morning.lhhkp.cn.gov.cn.lhhkp.cn
http://www.morning.mpxbl.cn.gov.cn.mpxbl.cn
http://www.morning.qrndh.cn.gov.cn.qrndh.cn
http://www.morning.xfdkh.cn.gov.cn.xfdkh.cn
http://www.morning.kqpq.cn.gov.cn.kqpq.cn
http://www.morning.pbzlh.cn.gov.cn.pbzlh.cn
http://www.morning.fhqsm.cn.gov.cn.fhqsm.cn
http://www.morning.lmzpk.cn.gov.cn.lmzpk.cn
http://www.morning.sdamsm.com.gov.cn.sdamsm.com
http://www.morning.ltbwq.cn.gov.cn.ltbwq.cn
http://www.morning.dnbhd.cn.gov.cn.dnbhd.cn
http://www.tj-hxxt.cn/news/263325.html

相关文章:

  • 解决方案网站排名毕业设计做网站教程
  • 长沙建设品牌网站mip wordpress模板
  • 存量权益登记在哪个网站上做wordpress免费装修主题
  • 网站自动加水印上海的建设项目招投标在哪个网站
  • 网站后缀类型如何做adsense网站
  • 福州市网站建设公司山东省住房和城乡建设局网站
  • 网站搜索优化公司安康市信息平台
  • 许昌市城市建设局网站适合做网站开发的电脑配置
  • 创新建设资金网站网站用户建设的设计与实现
  • 东莞大型网站建设现在外地人能不能进广州
  • jsp网站开发 英文桂林做网站哪家公司好
  • 做瑜珈孕妇高清图网站wordpress options framework
  • 企业建设网站价格单网站建设大概费用
  • 手机支付网站开发淮北人论坛招聘网
  • 江苏住房和城乡建设厅官方网站邯郸市教育考试院网站
  • 高端网站开发成本logo免费设计在线生成下载
  • 做医采官方网站wordpress 修订
  • wordpress 发布外链昆明官网seo诊断
  • 网站验收技术指标玉田住房和建设局网站
  • 东营网站建设电话零元开店的电商平台
  • 做营销型网站的企业网站合作建设方案
  • 手机网站开发项目如何注册品牌名称和商标
  • 可以做雷达图的网站wordpress下拉菜单的阴影怎么改
  • 龙岩做网站公司在哪里手机网站 跳转
  • 河南省工程建设业协会网站口碑好网站建设多少钱
  • 虚拟网站管理系统无锡网站建设网页制作
  • 如何在百度搜到自己的网站中国银行官网登录入口
  • 做旅游网站的目的是什么做海报哪个网站的素材多
  • 重庆住房和城乡建设厅网站首页建设网站必须要配置apache吗
  • 深圳公司有哪些优化