public static Adttendance DBSql(String data) throws SQLException {
    String url = "jdbc:mysql://localhost:3306/attendance?useUnicode=true&characterEncoding=utf8";
       String uid = "root";
       String pwd = "";
       Adttendance adttendance=null;
       if (DbUtils.loadDriver("com.mysql.jdbc.Driver")) {
       java.sql.Connection conn = DriverManager.getConnection(url, uid, pwd);
       String sql="select attrs from WT where id =?";
       QueryRunner runner=new QueryRunner();
       adttendance = (Adttendance) runner.query(conn, sql, new BeanHandler<Adttendance>(Adttendance.class), data);  
       System.out.println(adttendance.getAttrs()); 
       DbUtils.close(conn);
      }
    return adttendance;
    }
    
    public static int insertUser(Object schemaID,String data) throws SQLException
    {
        String url = "jdbc:mysql://localhost:3306/attendance?useUnicode=true&characterEncoding=utf8";
        String uid = "root";
        String pwd = "";
        int insertNum = 0;
        if(DbUtils.loadDriver("com.mysql.jdbc.Driver"))
        {
            java.sql.Connection conn = DriverManager.getConnection(url, uid, pwd);
            String sql = "insert into wt values(" + null + ",'" +schemaID + "','考勤表','描述信息','" + data + "','kq')";
            QueryRunner runner = new QueryRunner();
            insertNum = runner.update(conn, sql);
            // adttendance = runner.query(conn, sql, new BeanHandler<Adttendance>(Adttendance.class), data);
            // System.out.println(adttendance.getAttrs());
            DbUtils.close(conn);
        }
        return insertNum;
    }
    

DButils实现查询和新增的更多相关文章

  1. Java学习笔记 DbUtils数据库查询和log4j日志输出 使用

    DbUtils使用 QueryRunner DbUtils中定义了一个数据库操作类QueryRunner,所有的数据库操作CRUD都是通过此类来完成. 此类是线程安全的 方法名 对应sql语句 exc ...

  2. layui 学习笔记一:layui table 查询、新增、编辑、删除

    一.table数据的呈现(对应查询) 页面代码: @{ ViewBag.Title = "TableGrid"; } @section styles{ <link href= ...

  3. Linux用户查询、新增&删除

    1.查询用户tail -1 /etc/passwd 2.新增用户&用户组groupadd testgroup #组的添加useradd testuser #创建用户testuserpasswd ...

  4. (惊艳)对象序列化和反序列--Hibernate的查询和新增极其相似

    Hibernate几个关键字持久化,ORM(关系对象映射)(数据库中关系称作是一张表) 应用在项目中,刘一从写的查询代码,每次都挂掉,想要弄出测试数据,自己想着把查询出来的复杂数据弄到文件里自己要是去 ...

  5. http请求的GET和POST请求:查询和新增(ajax)

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  6. hive中为分区表增加字段需要注意默认不会修改已有分区的字段,导致查询时新增字段为null

    若向hive表添加字段,通常会使用下面这种语句 alter table default.testparquet add columns(c8 string); 但是对于分区表来说, 1. 若新建的分区 ...

  7. http请求的GET和POST请求:查询和新增(server.php)

    <?php //设置页面内容是html编码格式是utf-8 header("Content-Type: text/plain;charset=utf-8"); //heade ...

  8. dbutils基本使用

    dbutils的查询,主要用到的是query方法,增加,修改和删除都是update方法,update方法就不讲了 只要创建ResultSetHandler接口不同的实现类对象就可以得到想要的查询结果, ...

  9. 利用formatter原理自动化参数化查询

    前言:对于经常忙于服务端开发的小伙伴来说,与DB层打交道是在正常不过的事了,但是每次页面的查询条件新增往往意味着后端代码参数化同比增长,当然你可以不使用sqlhelper自带的参数化条件查询,可以直接 ...

随机推荐

  1. 第三十三课:jQuery Deferred详解1

    之前我们讲了Mochikit Deferred,JSDeferred,现在讲jQuery Deferred.首先,我们先来讲下他们的区别: 在保存回调函数时,Mochikit Deferred(doj ...

  2. Jquery实现异步上传图片

    利用jQuery的ajax函数就可以实现异步上传图片了.一开始我是想在处理程序中,直接用context.Request.Files来获取页面中的input file,但是不知道为什么一次获取不了.网上 ...

  3. Java Web整合开发实战:基于Struts 2+Hibernate+Spring 目录

    第1篇 Java Web开发基础第1章 Web的工作机制( 教学视频:31分钟) 1.1 理解Web的概念 1.1.1 Web的定义 1.1.2 Web的三个核心标准 1.2 C/S与B/S两种软件体 ...

  4. javascript与服务器1

    A. 通过在客户端设置Cookie,然后在服务器端读取它. 关于Cookie只说明一点, 它是存储在客户端机器上的一小块信息, 可以有客户端程序或服务器程序创建,并通过http传递.常用于跟踪用户在客 ...

  5. JS精粹:下半部分

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. The big deffrence between ($(du * )) and $(du *)

    Infolist=($(du *))echo "Get the list one $Infolist"This has formed a array after quating t ...

  7. 【CodeForces 626E】Simple Skewness

    题意 给出n个数的集合,求一个 (平均数-中位数)最大 (偏度最大)的子集,输出子集元素个数和各个元素(任意顺序). 分析 因为是子集,所以不一定是连续的序列.然后我们有下面几个结论. 1.最大偏度一 ...

  8. Teradata SQL tips

    Question: Insert into table_name  (1),(2),.... Teradata 貌似不能同时插入,只能一条一条插入,报错. 后来改为: Insert into tabl ...

  9. poj 3261 二分答案+后缀数组 求至少出现k次的最长重复子序列

    #include "stdio.h" #define maxn 20010 int wa[maxn],wb[maxn],wv[maxn],ws[maxn]; int rank[ma ...

  10. Android 设计模式 之 单例模式

    http://blog.csdn.net/fangchongbory/article/details/7734199   目录(?)[+] 单例模式常见情景 首先实现1中的单例模式A 实现2中单例模式 ...