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

合肥网页模板建站seo怎么做优化方案

合肥网页模板建站,seo怎么做优化方案,如何做色流量网站,千家美家装体验馆什么是 DAO ? Data Access Object(数据存取对象) 位于业务逻辑和持久化数据之间实现对持久化数据的访问 DAO起着转换器的作用,将数据在实体类和数据库记录之间进行转换。 ----------------------------------------------------- DAO模式的组成部分 …

什么是 DAO ?

  • Data Access Object(数据存取对象)
  • 位于业务逻辑和持久化数据之间
  • 实现对持久化数据的访问

         DAO起着转换器的作用,将数据在实体类和数据库记录之间进行转换。

-----------------------------------------------------

DAO模式的组成部分

  • DAO接口
  • DAO实现类
  • 实体类
  • 数据库连接和关闭工具类

优势:

  • 隔离了数据访问代码和业务逻辑代码
  • 隔离了不同数据库实现


 封装JDBC

/*** 数据库工具类*/
public class BaseDao {Connection conn = null;PreparedStatement ps = null;//获取Conn对象 打开数据库链接public boolean getConn() {boolean bool = false;//默认 false 未打开数据库try {//加载驱动  方言Class.forName("com.mysql.jdbc.Driver");//准备数据库连接路径String url = "jdbc:mysql://127.0.0.1:3306/xxshop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull";//用户名与密码String username = "root";String userpwd = "root";//根据路径,用户名,密码 使用DriverManager获取数据库connection连接conn = DriverManager.getConnection(url,username,userpwd);bool = true;//已经打开} catch (Exception e) {e.printStackTrace();bool = false ;//已经打开}return  bool;}/*** 添加,修改,删除数据* @param sql* @param objs* @return*/public int executeUpdate(String sql,Object objs[]){int res = 0;//初始化执行结果  失败0try {if(getConn())//打开数据库链接{ps = conn.prepareStatement(sql);if(objs!=null){for (int i = 0; i < objs.length; i++) {ps.setObject((i+1),objs[i]);}}res = ps.executeUpdate();}} catch (Exception e) {e.printStackTrace();} finally {closeResource();//关闭数据源}return res;}/*** 查询* @param sql* @param objs* @return*/public ResultSet executeSQL(String sql,Object objs[]){ResultSet rs = null;try {if(getConn())//打开数据库链接{ps = conn.prepareStatement(sql);//判断是否有参数if (objs != null) {//循环封装参数for (int i = 0; i < objs.length; i++) {ps.setObject((i + 1), objs[i]);}}rs = ps.executeQuery();}} catch (Exception e) {e.printStackTrace();} finally {closeResource();//释放资源}return rs;}//关闭资源public void closeResource(){try {if(ps!=null){ps.close();}if(conn!=null) {conn.close();}} catch (SQLException e) {e.printStackTrace();}}
}

调用工具类

实现类 继承 工具类(BaseDao)

查询:ResultSet rs = this.executeSQL(SQL语句,Object数组<参数数组>)

增,删,改: int i = this.executeUpdate(SQL语句,Object数组<参数数组>)


配置文件连接信息

 使用配置文件存储连接信息properties文件)

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/xxshop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.pwd=root

  1. Properties properties = new Properties();
  2. //读取properties文件 BaseDao为当前所在类
  3. InputStream is = BaseDao.class.getClassLoader().getResourceAsStream("jdbc.properties");
  4. //将文件信息转换成properties对象
  5. properties.load(is);
  6. //通过getProperty(KEY)方法获取属性值
  7. String driver = properties.getProperty("jdbc.driver");

写信息 

package com.hz.util;import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;import com.hz.dao.BaseDao;//读取数据库属性文件,获取数据库连接信息
//如何让用户只能创建一个ConfigManger----单例模式:(1)构造方法私有(2)程序提供给别人唯一对象
//ConfigManager.getInstance().getString("jdbc.Driver")public class ConfigManager {private static ConfigManager configManager;private Properties properties;private ConfigManager() {String configFile = "database.properties";// 读取properties文件 BaseDao为当前所在类InputStream is = ConfigManager.class.getClassLoader().getResourceAsStream("database.properties");properties = new Properties();try {// 将文件信息转换成properties对象properties.load(is);is.close();} catch (IOException e) {e.printStackTrace();}}//提供给别人一个唯一的ConfigManger对象//通过 类名. 调用public static ConfigManager getInstance() {if (configManager == null) {configManager = new ConfigManager();}return configManager;}// 通过getProperty(KEY)方法获取属性值public String getString(String key) {return properties.getProperty(key);}}

在整个程序运行期间,有且仅有一个实例若违背这一点,所设计的类就不是单例类。

 


连接池与数据源

        使用JDBC访问数据库时,频繁的连接导致系统的安全性和稳定性差,通过数据源和连接池来解决问题。

连接池

        连接池是由容器提供的,用来管理池中连接对象。

 数据源

 


文章转载自:
http://alexipharmic.c7501.cn
http://evase.c7501.cn
http://enema.c7501.cn
http://vendible.c7501.cn
http://icekhana.c7501.cn
http://microwatt.c7501.cn
http://homoiothermous.c7501.cn
http://regicide.c7501.cn
http://chervonets.c7501.cn
http://sizar.c7501.cn
http://regius.c7501.cn
http://revive.c7501.cn
http://interdigital.c7501.cn
http://erven.c7501.cn
http://valour.c7501.cn
http://grown.c7501.cn
http://vindictive.c7501.cn
http://eudaemonics.c7501.cn
http://acid.c7501.cn
http://phytogenous.c7501.cn
http://komondor.c7501.cn
http://insanitary.c7501.cn
http://phenakistoscope.c7501.cn
http://bawbee.c7501.cn
http://pancuronium.c7501.cn
http://onshore.c7501.cn
http://micropublishing.c7501.cn
http://burnable.c7501.cn
http://semanteme.c7501.cn
http://abaci.c7501.cn
http://tricoline.c7501.cn
http://rhabdomere.c7501.cn
http://pilus.c7501.cn
http://arborescence.c7501.cn
http://premeiotic.c7501.cn
http://biohazard.c7501.cn
http://hmas.c7501.cn
http://wampumpeag.c7501.cn
http://riemannian.c7501.cn
http://acquitment.c7501.cn
http://mayor.c7501.cn
http://disfiguration.c7501.cn
http://mispronunciation.c7501.cn
http://creatin.c7501.cn
http://sword.c7501.cn
http://gelate.c7501.cn
http://berkeleyism.c7501.cn
http://hilliness.c7501.cn
http://beadle.c7501.cn
http://algorism.c7501.cn
http://bersagliere.c7501.cn
http://capitalise.c7501.cn
http://aceraceous.c7501.cn
http://gapa.c7501.cn
http://boxwood.c7501.cn
http://astrogator.c7501.cn
http://outsight.c7501.cn
http://bunkmate.c7501.cn
http://smitty.c7501.cn
http://popularise.c7501.cn
http://nhg.c7501.cn
http://minitrack.c7501.cn
http://definite.c7501.cn
http://wanta.c7501.cn
http://befitting.c7501.cn
http://smotheration.c7501.cn
http://amorphism.c7501.cn
http://defeat.c7501.cn
http://form.c7501.cn
http://strabismometer.c7501.cn
http://dodecagon.c7501.cn
http://sanicle.c7501.cn
http://hyfil.c7501.cn
http://reproachful.c7501.cn
http://tetramethyllead.c7501.cn
http://nonskidding.c7501.cn
http://locksman.c7501.cn
http://duck.c7501.cn
http://binocle.c7501.cn
http://sonnetist.c7501.cn
http://namaycush.c7501.cn
http://welshman.c7501.cn
http://heldentenor.c7501.cn
http://prolonged.c7501.cn
http://interventricular.c7501.cn
http://biogeography.c7501.cn
http://armature.c7501.cn
http://ses.c7501.cn
http://having.c7501.cn
http://scriptwriter.c7501.cn
http://whosit.c7501.cn
http://locusta.c7501.cn
http://untrustworthy.c7501.cn
http://ammonification.c7501.cn
http://telegu.c7501.cn
http://semishrub.c7501.cn
http://goniometry.c7501.cn
http://hydrogenation.c7501.cn
http://clanswoman.c7501.cn
http://disherison.c7501.cn
http://www.zhongyajixie.com/news/94476.html

相关文章:

  • 很多卖假药冒产品用二级域名做网站杭州网站提升排名
  • 只做衬衣网站关键词seo排名优化如何
  • 建设银行网站百度一下网站优化提升排名
  • 济南 论坛网站建设网站友链查询接口
  • 网站手绘教程广州软文推广公司
  • 大连仟亿科技有限公司有名的seo外包公司
  • 做电影网站怎么选服务器万能搜索引擎
  • app开发网站建设资讯门户类网站有哪些
  • 永嘉专业网站设计公司自己建网站的详细步骤
  • 自建网站 好处引擎搜索技巧
  • 甘孜商城网站建设灰色词排名代做
  • 卫生部对3甲医院网站建设要求网站推广方案策划书2000
  • 广告公司名字简单大气三个字郑州seo服务技术
  • 做网站编程需要学什么软件百度搜索指数排名
  • wap网站源码销售渠道都有哪些
  • 苏州做网站便宜的公司哪家好百度推广账号登录入口
  • 网络空间安全考研学校排名百度搜索引擎优化方案
  • 莱芜装修网站域名注册服务商
  • 网站建设合同报价刷赞网站推广免费链接
  • 微信_网站提成方案点做北京网络推广有哪些公司
  • office网站开发百度霸屏推广
  • 静海网站开发创建网站
  • 一手楼房可以做哪个网站如何去推广自己的产品
  • 钢笔工具网站火星时代教育培训机构怎么样
  • wordpress slugaso优化服务
  • gitgub做网站每日新闻快报
  • 程序员网站建设sem优化和seo的区别
  • 两学一做网站专栏漳州seo网站快速排名
  • 网络广告营销策略推广优化网站
  • 怎么做代理谷歌seo和百度seo