张杰部落格
博客信息

备忘

发布时间:『 2017-07-24 14:10』  博客类别:Mysql  阅读(521) 评论(0)

SELECT * FROM t_post_0 WHERE 

url IN (SELECT url  FROM t_post_0 GROUP BY url HAVING  count(url) > 1)

and rowid not in (select min(rowid) from t_post_0 group by url having(url) > 1)



ALTER TABLE `t_post_0` ADD UNIQUE INDEX `un_url` (`url`) USING BTREE ;


import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

import java.io.RandomAccessFile;

import java.lang.reflect.Method;



public class ReflectUtil {

public static Object invoke(Object obj,String method,Object...param){

Class<?> cls=obj.getClass();

try {

if(param==null)

return cls.getDeclaredMethod(method).invoke(obj);

else{

Class<?>[] clss=new Class<?>[param.length];

for(int i=0;i<param.length;i++){

clss[i]=param[i].getClass();

}

return cls.getDeclaredMethod(method,clss).invoke(obj, param);

}

} catch (Exception e) {

LoggerUtil.error("execute method error", e);

throw new RuntimeException();

}

}

public static Object getInstance(String className){

try {

return Class.forName(className).newInstance();

} catch (Exception e) {

try {

Class<?> cls=Class.forName(className);

Method m=cls.getDeclaredMethod("getInstance");

return m.invoke(null);

} catch (Exception e1) {

return null;

}

}

}

public static void writeObject(Object obj,String path){

try {

RandomAccessFile raf = new RandomAccessFile(path, "rw");

ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(raf.getFD()));

oos.writeObject(obj);

oos.close();

raf.close();

} catch (Exception e) {

e.printStackTrace();

}

}

@SuppressWarnings("unchecked")

public static <T>T readObject(String path){

try {

RandomAccessFile raf= new RandomAccessFile(path, "rw");

ObjectInputStream ooi=new ObjectInputStream(new FileInputStream(raf.getFD()));

Object obj=ooi.readObject();

ooi.close();

raf.close();

return (T) obj;

} catch (Exception e) {

e.printStackTrace();

}

return null;

}

}


关键字:   无
评论信息
暂无评论
发表评论
验证码: 
Powered by IMZHANGJIE.CN Copyright © 2015-2021 粤ICP备14056181号