group='"+group+"'");
}
catch(Exception e)
{
e.printStackTrace();
}
return count;//返回删除联系人数目
}
//****************************联系人**************************************
public static String insertPerson(String uid,Vector
pInfo)
{
String isPathNull="isNotNull";//传过来的图像是不是合法,默认不为空
try{
con=getConnection();
if(pInfo.get(9).equals("")||pInfo.get(9)==null)
{
psInsert=con.prepareStatement("insert into lxy(pid,pname,pgender,page,pnumber,"+
"pemail,pgroup,ppostalcode,padress,uid)"+
"values(?,?,?,?,?,?,?,?,?,?)");
}
else
{
psInsert=con.prepareStatement("insert into lxy(pid,pname,pgender,page,pnumber,"+
"pemail,pgroup,ppostalcode,padress,uid,pphoto)"+
"values(?,?,?,?,?,?,?,?,?,?,?)" );
File f=new File(pInfo.get(9));
byte[] b=new byte[(int)f.length()];
FileInputStream fin=new FileInputStream(f);
fin.read(b);fin.close();
psInsert.setBytes(11,b);
}
for(int i=0;i<9;i++)
{
psInsert.setString(i+1,pInfo.get(i));
}
psInsert.setString(10,uid);
psInsert.execute();psInsert.close();
}
catch(FileNotFoundException fnfe){isPathNull="isNull";}
catch(Exception e){e.printStackTrace();}
finally{DButil.closeCon();}
return isPathNull;
}
public static String updatePerson(String uid,Vector pInfo){
String isPathNull="isNotNull";
try{
con=getConnection();
if(pInfo.get(9).equals("")||pInfo.get(9)==null)
{//更新时候,如果照片路径为空,则不更新图像
psInsert=con.prepareStatement("update lxy set pname=?,pgender=?,page=?,pnumber=?,"+
"pemail=?,pgroup=?,ppostalcode=?,padress=?,uid=? where pid='"+pInfo.get(0).trim()+"'");
}
else
{//如果照片路径不为空,则更新图像
psInsert=con.prepareStatement("update lxy set pname=?,pgender=?,page=?,pnumber=?,"+
"pemail=?,pgroup=?,ppostalcode=?,padress=?,uid=?,pphoto=? where pid='"+pInfo.get(0).trim()+"'");
File f=new File(pInfo.get(9));
byte[] b=new byte[(int)f.length()];
FileInputStream fin=new FileInputStream(f);
fin.read(b);fin.close();
psInsert.setBytes(10,b);
}
for(int i=1;i<9;i++){
psInsert.setString(i,pInfo.get(i));
}
psInsert.setString(9,uid);
psInsert.execute();psInsert.close();
}
catch(FileNotFoundException fnfe){isPathNull="isNull";}
catch(Exception e){e.printStackTrace();}
finally{DButil.closeCon();}
return isPathNull;
}
public static Vector getPerInfo(String sql)//得到联系人信息
{
Vector pInfo=new Vector();
try
{
con=getConnection();
stat=con.createStatement();
rs=stat.executeQuery(sql);
while(rs.next())
{
for(int i=1;i<10;i++)
{
pInfo.add(rs.getString(i));//将联系人信息添加到返回向量
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally{DButil.closeCon();}
return pInfo;
}
public static Image getPic(String sql)
{
Image i=null;
try
{
con=getConnection();
stat=con.createStatement();
rs=stat.executeQuery(sql);
while(rs.next())
{
byte[] buff=rs.getBytes(1);
if(buff!=null)
{
i=(new ImageIcon(buff)).getImage();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally{DButil.closeCon();}
return i;
}
//***********