2007-07-03
2007-06-29
和调用sql语句不同的是需要设置入参和出参
这篇文章已经说的很详细了。
http://www.delphibbs.com/keylife/iblog_show.asp?xid=28107
可是我配置的时候确怎么也得不到正确的结果,错误大致是“记录数太多”,查询了很多资料才发现原来Ibatis2.2之前是不支持存储过程返回CURSOR,所以请需要使用Ibatis调用存储过程并且获取记录集游标的同学注意了。下面帖一个我的配置:
-----------------------------------------------
<!-- 获取用户列表 -->
<resultMap id="rm_out_getUserList" class="java.util.HashMap">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="gname" column="gname" />
<result property="cname" column="cname" />
</resultMap>
<parameterMap id="pm_in_getUserList"
class="java.util.Map">
<parameter property="result" jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="rm_out_getUserList" />
<parameter property="p_name" jdbcType="VARCHAR2" javaType="java.lang.String" mode="IN" />
<parameter property="p_gname" jdbcType="VARCHAR2" javaType="java.lang.String" mode="IN" />
<parameter property="p_cname" jdbcType="VARCHAR2" javaType="java.lang.String" mode="IN" />
</parameterMap>
<procedure id="getUserList"
parameterMap="pm_in_getUserList">
{? = call PCK_USER.F_GET_USER(?,?,?)}
</procedure>
----------------------------------------------
绿色部分要注意(配置的第一行),如果是要将结果集以map形式返回,一定要写HashMap。
2007-06-22
如在oracle中有个package叫做PCK_VIEW,在PCK_VIEW里面有个F_GET_SITESNAPSHOT_TIME的函数有一个varchar2参数
-------------------------------------------
function F_GET_PARTNER_LIST(p_tmp varchar2)
return RecordSet
is
l_rs RecordSet;
begin
open l_rs for select partner from T_PARTNER order by UPPER(partner) asc;
return l_rs;
end F_GET_PARTNER_LIST;
-------------------------------------------
在ibatils里面配置调用是{ call PCK_VIEW.F_GET_SITESNAPSHOT_TIME(?) }
我确定参数都配置好了,但是调用的时候还是报错啊
-------------------------------------------
--- The error occurred in com/phoenixtv/stat/dao/ibatis/sql/realtime.xml. --- The error occurred while applying a parameter map. --- Check the stat.realtime.pm_in_getSiteSnapshotTime. --- Check the statement (update procedure failed). --- Cause: java.sql.SQLException: ORA-06550: line 1, column 7: PLS-00221: 'F_GET_SITESNAPSHOT_TIME' is not a procedure or is undefined ORA-06550: line 1, column 7:
-------------------------------------------
怎么回事,明明数据库有这个函数啊?
但是我在jdbc中这段代码确可以调用
-------------------------------------------
Class.forName("oracle.jdbc.driver.OracleDriver");
conn =DriverManager.getConnection("jdbc:oracle:thin:@111.111.111.111:1521:stat","pass","pass");
//conn = DBConnection.ins.getConn("jdbc/StatDB");sdf.format(new Date())+1
//conn = DBConnection.ins.getConn("statistic");
cs = conn.prepareCall("{? = call PCK_VIEW.F_GET_SITESNAPSHOT_TIME(?)}");
cs.registerOutParameter(1, OracleTypes.CURSOR);
cs.setString(2,"");
cs.execute();
rs =(ResultSet) cs.getObject(1);
--------------------------------------------
2007-05-18
2007-05-11
如何在IBatis中使用BLOB和CLOB
创建表:
REPORT {
id varchar2(5),
name varchar2(25),
description varchar2(1000),
data BLOB
}创建表对应的POJO:
/*
* Report.java
*
* Created on March 23, 2005, 11:00 AM
*/
package reporting.viewer.domain;
/**
*
* @author Nathan Maves
*/
public class Report {
/**
* Holds value of property id.
*/
private String id;
/**
* Holds value of property name.
*/
private String name;
/**
* Holds value of property description.
*/
private String id;
/**
* Holds value of property data.
*/
private byte[] data;
//Standard accessors and mutators
public byte[] getData() {
return this.data;
}
public void setData(byte[] data) { this.data = data; }
}
iBatis配置文件:
<typeAlias alias="Report" type="reporting.viewer.domain.Report"/>
<resultMap class="Report" id="ReportResult"> <result column="id" property="id" /> <result column="name" property="name" /> <result column="description" property="description" /> <result column="data" property="data" jdbcType="BLOB"/> </resultMap>
<select id="getReportById" parameterClass="string" resultMap="ReportResult">
SELECT
*
FROM
REPORT
WHERE
id = #value#
</select>
<insert id="insertReport" parameterClass="Report">
INSERT INTO
REPORT (
id,
name,
description,
data
)
values (
#id#,
#name#,
#description#,
#data#
)
</insert>
<update id="updateReport" parameterClass="Report">
UPDATE REPORT set
name = #name#,
description = #description#,
data = #data#
WHERE
id = #id#
</update>
更多请看http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+BLOB+or+CLOB
svchost.exe占CPU 100%的解决方法
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明。
http://www.chedong.com/blog/archives/001286.html
现象:
- 机器启动运行几分钟后 svchost.exe就会占系统cpu资源的100%
- 拔掉网线就好了,重连上网后一会儿:svchost.exe又占cpu资源的99%;
解决:
假设你已经使用了免费杀毒软件排除了病毒和已经使用防间谍软件排除了恶意软件的影响:
想办法清空C:WINDOWSSoftwareDistribution 目录下所有的文件重启机器即可。
如果机器提示文件正在使用("Automatic Updates"服务正在运行)无法删除相应目录:
- 则想办法打开控制面板==>管理工具==>服务,找到"Automatic Updates",设置成手动启动,
- 重启后再删除 C:WINDOWSSoftwareDistribution。问题就解决了。
- 然后再打开控制面板==>管理工具==>服务,找到"Automatic Updates",恢复成自动启动重启。
注意:重启后最好在上网条件比较好的地方让系统顺利完成一次系统自动更新。
推广: 遇到类似问题的应该挺多的,如果你也发现这个方法有用,请将 http://www.chedong.com/blog/archives/001286.html
这个链接加到你的blog里。
html代码: <a xhref="http://www.chedong.com/blog/archives/001286.html">svchost.exe</a>
原因分析:
先说说什么是svchost.exe:简单的说没有这个服务机器几乎就上不了网了。很多应用服务都是以来于这个接口RPC的,如果发现这个进程占了太多的CPU资源,
直接把系统的RPC服务禁用了会是一场灾难:因为连恢复这个界面的系统服务设置界面都无法使用了。恢复的方法需要使用注册表编辑器,找到 HKEY_LOCAL_MACHINE >> SYSTEM >> CurrentControlSet >> Services >> RpcSs, 右侧找到Start属性,把它的值改为2再重启即可
造成svchost占系统CPU 100%的原因并非svchost服务本身:以上的情况是由于Windows Update服务下载/安装失败而导致更新服务反复重试造成的。而Windows的自动更新也是依赖于svchost服务的一个后台应用,从而表现为svchost.exe负载极高。 常发生这类问题的机器一般是上网条件(尤其是去国外网站)不稳定的机器,比如家里的父母的机器,往往在安装机器几个月以后不定期发生,每个月的第二个星期是高发期:因为最近几年MS很有规律的在每个月的第二个星期发布补丁程序)。
上面的解决方法并不能保证不重发作,但是为了svchost文件而每隔几个月重装一次操作系统还是太浪费时间了。
教训:spoolsv.exe和svchost.exe的问题都是应用遇到失败/例外情况后自动重试造成的,本想为用户节省时间的设计,但是重试的频度过高反而导致了和病毒一样的效果。
参考资料: