随笔分类 -  java

java map排序
摘要:public void statisticsA(){ List<Moves> file = this.file(); Map<String,Integer> map = new HashMap<>(); int init=1; for (Moves moves1 : file) { if("".eq 阅读全文

posted @ 2020-11-26 20:04 Difcipo 阅读(89) 评论(0) 推荐(0)

java编写一个简单的验证码
摘要:public class ImageServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletExcepti 阅读全文

posted @ 2020-11-23 21:03 Difcipo 阅读(123) 评论(0) 推荐(0)

DBUtil工具类
摘要:1. 添加jar包 2. 获取数据源对象; DataSource ds = DataSourceUtil.getDataSource();//自己写的工具类 3. 获取QueryRunner对象 QueryRunner qr = new QueryRunner(ds); 修改:runner.upda 阅读全文

posted @ 2020-11-21 21:30 Difcipo 阅读(116) 评论(0) 推荐(0)

JdbcTemplate
摘要:1.导入jar包 2.创建JdbcTemplate对象,依赖于数据源DataSource JdbcTemplate jt = new JdbcTemplate(new ComboPooledDataSource()); //依赖于数据源DataSource 3.调用JdbcTemplate方法来完成 阅读全文

posted @ 2020-11-21 18:59 Difcipo 阅读(106) 评论(0) 推荐(0)

抽取jdbc工具类JdbcUtil
摘要:1.在src下创建一个jdbc.properties文件 url=jdbc:mysql:///demo user=root password=123 driver=com.mysql.jdbc.Driver 2.编写工具类 public class JdbcUtil { private static 阅读全文

posted @ 2020-11-21 11:27 Difcipo 阅读(143) 评论(0) 推荐(0)

使用c3p0链接数据库
摘要:1.导入jar包c3p0-0.9.1.2.jar , mchange-commons-java-0.2.19.jar 2.定义配置文件 名称:c3p0-config.xml <?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <default-c 阅读全文

posted @ 2020-11-21 10:56 Difcipo 阅读(138) 评论(0) 推荐(0)

使用jdbc连接数据库
摘要:1.导入jar包 mysql-connector-java-5.1.7-bin.jar。并加入到环境中。 2.注册驱动,获取连接 //注册驱动 Class.forName("com.mysql.jdbc.Driver");//com.mysql.jdbc.Driver mysql驱动 //获取链接 阅读全文

posted @ 2020-11-21 10:26 Difcipo 阅读(81) 评论(0) 推荐(0)

构造函数,静态代码块,匿名代码块的执行顺序
摘要:1.静态代码块 static{ System.out.println("Child静态代码块"); } 2.匿名代码块 { System.out.println("Child匿名代码块"); } 3.构造方法 public Child(String name){ super(name); Syste 阅读全文

posted @ 2020-11-20 18:32 Difcipo 阅读(122) 评论(0) 推荐(0)

导航