//更新图层元数据
public static boolean updateLayerMetadataByID(DataSource ds,String id,String xml)throws SQLException,ClassNotFoundException{
boolean flag=false;
Connection con=null;
try{
String metadataTableName=DBUtil.getLayerMetadataTableName(ds);
StringBuffer buffer=new StringBuffer("Update ");
buffer.append(metadataTableName);
buffer.append(" SET DATACOL = ? WHERE RECORDID = ?");
// buffer.append(id);
// buffer.append("'");
con=DBUtil.getConnection(ds);
logger.info("excute sql:"+buffer.toString());
OraclePreparedStatement ste=(OraclePreparedStatement)con.prepareStatement(buffer.toString());
XMLType xmltype=XMLType.createXML(con, xml);
ste.setObject(1, xmltype);
ste.setString(2, id);
//boolean result = false;
//try{
ste.execute();
flag = true;
//_log.info("execute sql : " + sql.toString() + " successful.");
//} finally {
if(ste != null) {
ste.close();
ste = null;
}
//}
}catch(ClassNotFoundException e){
flag=false;
throw new ClassNotFoundException(e.getMessage());
}catch(SQLException e){
flag=false;
throw new SQLException(e);
}finally{
try{
DBUtil.closeConnection(con);
}
catch(SQLException e){
flag=false;
throw new SQLException(e);
};
}
return flag;
};
转载请注明出处,欢迎交流!http://www.cnblogs.com/likehua