就像判断字符串似的 select * from articles where sexs is not null;
类似上面条件二进制有吗? 

解决方案 »

  1.   

    同样可以 IS NULL 啊。楼主的问题具体是什么? 那就举例说明。
      

  2.   

    我也不知道为什么,我插入一个null,数据库自动变成0000,为什么呢?
      

  3.   

    show create table articles ; 贴出来。是不是有默认值啊? 或者有没有触发器?
      

  4.   

    你的建表语句是什么,检查一下是否有DEFAULT值 OR TRIGGER
      

  5.   

    我往oracle数据库里插入2进制文件,直接insert语句是无法插进去
    后来网上找了找资料,说需要3步:1.插入一个空,2.查询出来二禁止,3.往里面赋值。。public void insertTraitStrTrees(List<TraitStrTrees> list, String tableName) {        connect();
            sql = "insert into " + tableName + " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            System.out.println(sql);
            try {
                conn.setAutoCommit(false);
                int isCommit = 0;
                for (int i = 0; i < list.size(); i++) {
                    isCommit++;
                    ps = conn.prepareStatement(sql);
                    ps.setInt(1, list.get(i).getDg_id());
                    ps.setInt(2, list.get(i).getId());
                    ps.setString(3, list.get(i).getTrait_value());
                    ps.setInt(4, list.get(i).getParent_id());
                    ps.setInt(5, list.get(i).getChild_id());
                    ps.setInt(6, list.get(i).getLeft_id());
                    ps.setInt(7, list.get(i).getRight_id());                ps.setBlob(8, BLOB.getEmptyBLOB());
                    ps.setBlob(9, BLOB.getEmptyBLOB());
                    ps.setBlob(10, BLOB.getEmptyBLOB());
                    ps.setBlob(11, BLOB.getEmptyBLOB());
                    ps.setBlob(12, BLOB.getEmptyBLOB());
                    ps.setBlob(13, BLOB.getEmptyBLOB());
                    ps.setBlob(14, BLOB.getEmptyBLOB());                ps.setInt(15, list.get(i).isFrist());
                    ps.setInt(16, list.get(i).isHasChild());
                    ps.executeUpdate();
                    //ps.close();
                    String sql1 = "select articles,pictures,tables,videos,audios,ads,pages from " + tableName + " where dg_id=" + list.get(i).getDg_id() + " and id=" + list.get(i).getId() + " FOR UPDATE";
                    ps = conn.prepareStatement(sql1);                ResultSet rs = ps.executeQuery();
                    rs.next();
                    BLOB articles = (BLOB) rs.getBlob(1);
                    BLOB pictures = (BLOB) rs.getBlob(2);
                    BLOB tables = (BLOB) rs.getBlob(3);
                    BLOB videos = (BLOB) rs.getBlob(4);
                    BLOB audios = (BLOB) rs.getBlob(5);
                    BLOB ads = (BLOB) rs.getBlob(6);
                    BLOB pages = (BLOB) rs.getBlob(7);                OutputStream out1 = articles.getBinaryOutputStream();
                    OutputStream out2 = pictures.getBinaryOutputStream();
                    OutputStream out3 = tables.getBinaryOutputStream();
                    OutputStream out4 = videos.getBinaryOutputStream();
                    OutputStream out5 = audios.getBinaryOutputStream();
                    OutputStream out6 = ads.getBinaryOutputStream();
                    OutputStream out7 = pages.getBinaryOutputStream();
                    try {
                        out1.write(list.get(i).getArticles());
                        out1.close();
                        out2.write(list.get(i).getPictures());
                        out2.close();
                        out3.write(list.get(i).getTables());
                        out3.close();
                        out4.write(list.get(i).getVideos());
                        out4.close();
                        out5.write(list.get(i).getAudios());
                        out5.close();
                        out6.write(list.get(i).getAds());
                        out6.close();
                        out7.write(list.get(i).getPages());
                        out7.close();
                    } catch (IOException ex) {
                        Logger.getLogger(MysqlDB.class.getName()).log(Level.SEVERE, null, ex);
                    }                String sql2 = "update " + tableName + " set articles=? , pictures=? , tables=? , videos=? , audios=? , ads=? , pages=? where dg_id=" + list.get(i).getDg_id() + " and id=" + list.get(i).getId();
                    ps = conn.prepareStatement(sql2);
                    ps.setBlob(1, articles);
                    ps.setBlob(2, pictures);
                    ps.setBlob(3, tables);
                    ps.setBlob(4, videos);
                    ps.setBlob(5, audios);
                    ps.setBlob(6, ads);
                    ps.setBlob(7, pages);                ps.executeUpdate();
                    ps.addBatch();
                    if (isCommit % 50 == 0) {
                        ps.executeBatch();
                        conn.commit();
                        ps.close();
                        close();
                        connect();
                    } else if (i == list.size() - 1) {
                        ps.executeBatch();
                        conn.commit();
                        ps.close();
                        close();
                    }
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                close();
            }    }
      

  6.   

    大哥,你又不贴create语句,insert也没有字段名,谁知道哪个语句对应sexs字段
    另外,你前N个PreparedStatement都没有关闭,也许不会引起大问题,但是这终究不是一个好习惯!!!