jdbc查询数据库模板

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/boywcx/article/details/82228447


        
       
        Connection conn = null;
        PrintWriter out = null;
        PreparedStatement statement = null;
        ResultSet rs = null;
  
        try {
        conn = new DBConnect().getConnect();
        String strsql = "select * from mt_audit_zbz_table where zbz_id = ?";
         statement =conn.prepareStatement(strsql);
         statement.setString(1, uuid);
        rs= statement.executeQuery();

        while(rs.next()){
        String table_id = rs.getString("table_id");
        String data_year = rs.getString("data_year");
        System.out.println("the fname is " + "table_id="+table_id+"data_year="+data_year);
        }
        }
        catch (Exception e) {
        log.error(e, e);
        }finally{
            try {
                rs.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                statement.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                conn.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
        }

 

猜你喜欢

转载自blog.csdn.net/boywcx/article/details/82228447
今日推荐