您的当前位置:首页正文

Error setting null for parameter #1with JdbcType OTHER .

2023-11-11 来源:帮我找美食网

Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 无效的列类型: 1111

 

传入的第一个参数值为空“parameter #1”

Error setting null for parameter #1with JdbcType OTHER .

标签:parameter   第一个   property   different   setting   config   type   cep   for   

小编还为您整理了以下内容,可能对您也有帮助:

mybatis报错:Error setting null for parameter #1 with JdbcType OTHER

修改mybatis对于插入空数据的jdbcTypeForNull默认值,解决方法如下:

1、在字段上添加注解,el = " 字段名, jdbcType=字段类型 "。

2、或者修改配置文件 application.yml。

3、通过序列或任意SQL获取主键值,tagId作为主键是不能为null插入。

4、再不行就将注解生成策略做个修改。

mybatis中Errorsetting null forparameter #2 怎么解决??

适配oracle数据库的时候,mybatis报了Error setting null parameter,bug发现是参数出现了null值,对于Mybatis,如果进行操作的时候,没有指定jdbcType类型的参数,就可能导致问题。

postgreSQL,MySQL,SQLSERVER都支持JdbcType.NULL类型,Oracle是不支持,适配的时候也因为这个问题导致mybatis报错。

比如,之前配置#{submitDate},它会在oracle中报错:Error setting null parameter

更改成#{submitDate,jdbcType=DATE},注意jdbcType是区分大小写的。

mybatis中Errorsetting null forparameter #2 怎么解决??

适配oracle数据库的时候,mybatis报了Error setting null parameter,bug发现是参数出现了null值,对于Mybatis,如果进行操作的时候,没有指定jdbcType类型的参数,就可能导致问题。

postgreSQL,MySQL,SQLSERVER都支持JdbcType.NULL类型,Oracle是不支持,适配的时候也因为这个问题导致mybatis报错。

比如,之前配置#{submitDate},它会在oracle中报错:Error setting null parameter

更改成#{submitDate,jdbcType=DATE},注意jdbcType是区分大小写的。

ibatis 怎么返回oracle游标

问题总结:

1.index by表不能存储在数据库中的type中,故选择嵌套表。

2.ibatis不支持oracle的复合数据类型的返回。(个人理解)

3.替代方案:用返回oracle游标来代替复合数据类型。ibatis能接受oracle游标类型。

注意此处是ibatis2.3

部分代码:

1.java

复制代码
1 private Map<String,Object> userStateResult(Users users)throws Exception{
2 Map<String,Object> param = new HashMap<String,Object>();
3 param.put("PRM_USERID", users.getUserid().toString());
4 param.put("PRM_OBJECTS", null);
5 param.put("PRM_TAGS", null);
6 param.put("PRM_APPCODE", null);
7 param.put("PRM_ERRMSG", null);
8 getDao().queryForList("user.prc_user_index",param);
9 if(Constant.SUCCESS.equals(param.get("PRM_APPCODE"))){
10 return param;
11 }else{
12 return null;
13 }
14 }
复制代码
返回值(包括游标的返回值)都在param这个map中

2.ibatis代码:

复制代码
1 <parameterMap class="java.util.Map" id="UserIndexParam">
2 <parameter property="PRM_USERID" javaType="java.lang.String"
3 jdbcType="VARCHAR" mode="IN" />
4 <parameter property="PRM_OBJECTS" javaType="java.sql.ResultSet"
5 jdbcType="ORACLECURSOR" mode="OUT" resultMap="ref_object" />
6 <parameter property="PRM_TAGS" javaType="java.sql.ResultSet"
7 jdbcType="ORACLECURSOR" mode="OUT" resultMap="ref_tag" />
8 <parameter property="PRM_APPCODE" javaType="java.lang.String"
9 jdbcType="VARCHAR" mode="OUT" />
10 <parameter property="PRM_ERRMSG" javaType="java.lang.String"
11 jdbcType="VARCHAR" mode="OUT" />
12 </parameterMap>
13 ---------------------------------------------------------------------------------
14 <resultMap id="ref_tag" class="com.diy.tag.entity.Tag">
15 <result column="tagid" jdbcType="VARCHAR" property="tagid" />
16 <result column="tagname" jdbcType="VARCHAR" property="name" />
17 </resultMap>
18
19 <resultMap class="com.diy.comm.cursorHandler.ObjectHandler" id="ref_object">
20 <result column="OBJECTID" jdbcType="DECIMAL" property="objectid" />
21 <result column="OWNERID" jdbcType="DECIMAL" property="ownerid" />
22 <result column="DBUSID" jdbcType="DECIMAL" property="dbusid" />
23 <result column="DUSERSID" jdbcType="DECIMAL" property="sersid" />
24 <result column="TAGID" jdbcType="VARCHAR" property="tagid" />
25 <result column="USERNAME" jdbcType="VARCHAR" property="username" />
26 <result column="OBJNAME" jdbcType="VARCHAR" property="objname" />
27 <result column="LOVENUM" jdbcType="DECIMAL" property="lovenum" />
28 <result column="INRUDUCTION" jdbcType="VARCHAR" property="inruction" />
29 <result column="CATAGROY" jdbcType="DECIMAL" property="catagroy" />
30 <result column="IMAGEPATH" jdbcType="VARCHAR" property="imagepath" />
31 </resultMap>
32 ---------------------------------------------------------------------------
33 <procere id="prc_user_index" parameterMap="UserIndexParam">
34 {call
35 PKG_USER.PRC_USER_INDEXVIEW(?,?,?,?,?)}
36 </procere>
复制代码
有一篇文章写的很好:大家可以参考一下http://blog.sina.com.cn/s/blog_80c111410100vgsh.html

但是对于本问题没有用ibatis的TypeHandler。

因为存储过程调试可以返回游标数据,但是ibatis接受的到全部是null。不知道原因,有知道的朋友可以留言一下。

我个人猜测可能是ibatis版本问题。

3.存储过程代码(部分):

复制代码
--对象类型
CREATE OR REPLACE TYPE TAGS_INFO IS object
(
TAGID number,
TAGNAME varchar2(200)
)
--嵌套表
CREATE OR REPLACE TYPE table_tag IS TABLE OF TAGS_INFO
注意对象和嵌套表都要放在全局的。不能定义在包体中
--兴趣游标
TYPE TAGCURSOR IS REF CURSOR;
--东西游标
TYPE OBJECTCURSOR IS REF CURSOR;--这个定义在包体中
------------------------------------------------------------------------
PROCEDURE PRC_USER_INDEXVIEW(PRM_USERID IN VARCHAR2,
PRM_OBJECTS OUT OBJECTCURSOR,
PRM_TAGS OUT TAGCURSOR,
PRM_APPCODE OUT VARCHAR2,
PRM_ERRMSG OUT VARCHAR2) IS
N_FLAG NUMBER;
VAR_FIRSTTAG VARCHAR2(100);
VAR_DUSERID VARCHAR2(100);
INDEX_TAGS TABLE_TAG;

--用户兴趣标签
CURSOR CUR_USERTAG IS
SELECT C.TAGID, C.NAME
FROM USERSDETIAL A, TAGRELATION B, TAG C
WHERE A.DUSERSID = B.DUSERSID
AND B.TAGID = C.TAGID
AND A.DUSERSID = VAR_DUSERID;
--公共兴趣标签
CURSOR CUR_USERPUB IS
SELECT T.*
FROM (SELECT ROWNUM AS RNUM,
COUNT(A.DUSERSID) AS CNUM,
B.TAGID,
B.NAME
FROM TAGRELATION A, TAG B
WHERE A.TAGID = B.TAGID
GROUP BY A.DUSERSID, B.TAGID, B.NAME, ROWNUM) T
WHERE RNUM <= 8
ORDER BY T.CNUM DESC;
--object
/*CURSOR CUR_OBJ(VAR_TAGID VARCHAR2) IS
SELECT ROWNUM AS RN, A.*
FROM OBJECT A
WHERE trim(A.TAGID) = VAR_TAGID
AND ROWNUM < 30;*/

REC_USERTAG CUR_USERTAG%ROWTYPE;
REC_USERPUB CUR_USERPUB%ROWTYPE;
--REC_OBJ OBJECT%ROWTYPE;
BEGIN
PRM_APPCODE := PKG_COMM.DEF_OK;
PRM_ERRMSG := '';

IF PRM_USERID IS NULL THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '参数未定义';
RETURN;
END IF;
--用户详细ID是否存在
SELECT B.DUSERSID
INTO VAR_DUSERID
FROM USERS A, USERSDETIAL B
WHERE A.USERID = B.USERSID
AND A.USERID = PRM_USERID;
IF VAR_DUSERID IS NULL THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '参数无效';
RETURN;
END IF;
--1.判断是否为有效用户
SELECT NVL(A.FLAG, 1)
INTO N_FLAG
FROM USERS A, USERSDETIAL B
WHERE A.USERID = B.USERSID
AND B.DUSERSID = VAR_DUSERID;

IF N_FLAG = 1 THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '用户已被禁止登录';
RETURN;
END IF;

--2.判断用户是否有兴趣tag

FOR REC_USERTAG IN CUR_USERTAG LOOP
INDEX_TAGS := TABLE_TAG();
IF CUR_USERTAG%ROWCOUNT = 0 THEN
--获取公共兴趣游标
FOR REC_USERPUB IN CUR_USERPUB LOOP
INDEX_TAGS.EXTEND;
IF CUR_USERPUB%ROWCOUNT = 1 THEN
VAR_FIRSTTAG := REC_USERPUB.TAGID;
END IF;
INDEX_TAGS(CUR_USERPUB%ROWCOUNT) := TAGS_INFO(REC_USERPUB.TAGID,
REC_USERPUB.NAME);
END LOOP;
ELSIF CUR_USERTAG%ROWCOUNT = 1 THEN
VAR_FIRSTTAG := REC_USERTAG.TAGID;
END IF;
INDEX_TAGS.EXTEND;
INDEX_TAGS(CUR_USERTAG%ROWCOUNT) := TAGS_INFO(REC_USERTAG.TAGID,
REC_USERTAG.NAME);
--index_tags(CUR_USERTAG%ROWCOUNT).TAGNAME := REC_USERTAG.NAME;

END LOOP;

IF INDEX_TAGS.COUNT <> 0 THEN
/* --3. 取出object
FOR REC_OBJ IN CUR_OBJ(VAR_FIRSTTAG) LOOP
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).OWNERID := REC_OBJ.OWNERID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).OBJECTID := REC_OBJ.OBJECTID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).DBUSID := REC_OBJ.DBUSID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).DUSERSID := REC_OBJ.DUSERSID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).TAGID := REC_OBJ.TAGID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).LOVENUM := REC_OBJ.LOVENUM;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).INRUDUCTION := REC_OBJ.INRUDUCTION;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).CATAGROY := REC_OBJ.CATAGROY;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).Imagepath := REC_OBJ.Imagepath;

END LOOP;*/
--返回东西游标
OPEN PRM_OBJECTS FOR
SELECT ROWNUM AS RN, A.*, B.USERNAME
FROM OBJECT A, USERSDETIAL B
WHERE A.OWNERID = B.DUSERSID
AND TRIM(A.TAGID) = VAR_FIRSTTAG
AND ROWNUM < 30;

END IF;
--tag游标
OPEN PRM_TAGS FOR
SELECT * FROM TABLE(CAST(INDEX_TAGS AS TABLE_TAG));

EXCEPTION
WHEN OTHERS THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '获取主界面数据失败' || '错误原因:' || PRM_ERRMSG || '-' || SQLERRM ||
'错误行数:' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE();
END;
---注意:a.返回游标的用open for 方法,不用关心游标的关闭。它是自动关闭的。原因:调试把游标返回值点几下,你就回发现。
b.如果报错CURSOR IS CLOESD的话,说明游标里面没有数据。所以open for 必须保证有select中有数据
c.嵌套表这里要用类似与java的构造方法写,如上
如果写成类似于java中new对象后,用set方法给嵌套表赋值的,会报错未能未能初始化的结果集。

ibatis 怎么返回oracle游标

问题总结:

1.index by表不能存储在数据库中的type中,故选择嵌套表。

2.ibatis不支持oracle的复合数据类型的返回。(个人理解)

3.替代方案:用返回oracle游标来代替复合数据类型。ibatis能接受oracle游标类型。

注意此处是ibatis2.3

部分代码:

1.java

复制代码
1 private Map<String,Object> userStateResult(Users users)throws Exception{
2 Map<String,Object> param = new HashMap<String,Object>();
3 param.put("PRM_USERID", users.getUserid().toString());
4 param.put("PRM_OBJECTS", null);
5 param.put("PRM_TAGS", null);
6 param.put("PRM_APPCODE", null);
7 param.put("PRM_ERRMSG", null);
8 getDao().queryForList("user.prc_user_index",param);
9 if(Constant.SUCCESS.equals(param.get("PRM_APPCODE"))){
10 return param;
11 }else{
12 return null;
13 }
14 }
复制代码
返回值(包括游标的返回值)都在param这个map中

2.ibatis代码:

复制代码
1 <parameterMap class="java.util.Map" id="UserIndexParam">
2 <parameter property="PRM_USERID" javaType="java.lang.String"
3 jdbcType="VARCHAR" mode="IN" />
4 <parameter property="PRM_OBJECTS" javaType="java.sql.ResultSet"
5 jdbcType="ORACLECURSOR" mode="OUT" resultMap="ref_object" />
6 <parameter property="PRM_TAGS" javaType="java.sql.ResultSet"
7 jdbcType="ORACLECURSOR" mode="OUT" resultMap="ref_tag" />
8 <parameter property="PRM_APPCODE" javaType="java.lang.String"
9 jdbcType="VARCHAR" mode="OUT" />
10 <parameter property="PRM_ERRMSG" javaType="java.lang.String"
11 jdbcType="VARCHAR" mode="OUT" />
12 </parameterMap>
13 ---------------------------------------------------------------------------------
14 <resultMap id="ref_tag" class="com.diy.tag.entity.Tag">
15 <result column="tagid" jdbcType="VARCHAR" property="tagid" />
16 <result column="tagname" jdbcType="VARCHAR" property="name" />
17 </resultMap>
18
19 <resultMap class="com.diy.comm.cursorHandler.ObjectHandler" id="ref_object">
20 <result column="OBJECTID" jdbcType="DECIMAL" property="objectid" />
21 <result column="OWNERID" jdbcType="DECIMAL" property="ownerid" />
22 <result column="DBUSID" jdbcType="DECIMAL" property="dbusid" />
23 <result column="DUSERSID" jdbcType="DECIMAL" property="sersid" />
24 <result column="TAGID" jdbcType="VARCHAR" property="tagid" />
25 <result column="USERNAME" jdbcType="VARCHAR" property="username" />
26 <result column="OBJNAME" jdbcType="VARCHAR" property="objname" />
27 <result column="LOVENUM" jdbcType="DECIMAL" property="lovenum" />
28 <result column="INRUDUCTION" jdbcType="VARCHAR" property="inruction" />
29 <result column="CATAGROY" jdbcType="DECIMAL" property="catagroy" />
30 <result column="IMAGEPATH" jdbcType="VARCHAR" property="imagepath" />
31 </resultMap>
32 ---------------------------------------------------------------------------
33 <procere id="prc_user_index" parameterMap="UserIndexParam">
34 {call
35 PKG_USER.PRC_USER_INDEXVIEW(?,?,?,?,?)}
36 </procere>
复制代码
有一篇文章写的很好:大家可以参考一下http://blog.sina.com.cn/s/blog_80c111410100vgsh.html

但是对于本问题没有用ibatis的TypeHandler。

因为存储过程调试可以返回游标数据,但是ibatis接受的到全部是null。不知道原因,有知道的朋友可以留言一下。

我个人猜测可能是ibatis版本问题。

3.存储过程代码(部分):

复制代码
--对象类型
CREATE OR REPLACE TYPE TAGS_INFO IS object
(
TAGID number,
TAGNAME varchar2(200)
)
--嵌套表
CREATE OR REPLACE TYPE table_tag IS TABLE OF TAGS_INFO
注意对象和嵌套表都要放在全局的。不能定义在包体中
--兴趣游标
TYPE TAGCURSOR IS REF CURSOR;
--东西游标
TYPE OBJECTCURSOR IS REF CURSOR;--这个定义在包体中
------------------------------------------------------------------------
PROCEDURE PRC_USER_INDEXVIEW(PRM_USERID IN VARCHAR2,
PRM_OBJECTS OUT OBJECTCURSOR,
PRM_TAGS OUT TAGCURSOR,
PRM_APPCODE OUT VARCHAR2,
PRM_ERRMSG OUT VARCHAR2) IS
N_FLAG NUMBER;
VAR_FIRSTTAG VARCHAR2(100);
VAR_DUSERID VARCHAR2(100);
INDEX_TAGS TABLE_TAG;

--用户兴趣标签
CURSOR CUR_USERTAG IS
SELECT C.TAGID, C.NAME
FROM USERSDETIAL A, TAGRELATION B, TAG C
WHERE A.DUSERSID = B.DUSERSID
AND B.TAGID = C.TAGID
AND A.DUSERSID = VAR_DUSERID;
--公共兴趣标签
CURSOR CUR_USERPUB IS
SELECT T.*
FROM (SELECT ROWNUM AS RNUM,
COUNT(A.DUSERSID) AS CNUM,
B.TAGID,
B.NAME
FROM TAGRELATION A, TAG B
WHERE A.TAGID = B.TAGID
GROUP BY A.DUSERSID, B.TAGID, B.NAME, ROWNUM) T
WHERE RNUM <= 8
ORDER BY T.CNUM DESC;
--object
/*CURSOR CUR_OBJ(VAR_TAGID VARCHAR2) IS
SELECT ROWNUM AS RN, A.*
FROM OBJECT A
WHERE trim(A.TAGID) = VAR_TAGID
AND ROWNUM < 30;*/

REC_USERTAG CUR_USERTAG%ROWTYPE;
REC_USERPUB CUR_USERPUB%ROWTYPE;
--REC_OBJ OBJECT%ROWTYPE;
BEGIN
PRM_APPCODE := PKG_COMM.DEF_OK;
PRM_ERRMSG := '';

IF PRM_USERID IS NULL THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '参数未定义';
RETURN;
END IF;
--用户详细ID是否存在
SELECT B.DUSERSID
INTO VAR_DUSERID
FROM USERS A, USERSDETIAL B
WHERE A.USERID = B.USERSID
AND A.USERID = PRM_USERID;
IF VAR_DUSERID IS NULL THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '参数无效';
RETURN;
END IF;
--1.判断是否为有效用户
SELECT NVL(A.FLAG, 1)
INTO N_FLAG
FROM USERS A, USERSDETIAL B
WHERE A.USERID = B.USERSID
AND B.DUSERSID = VAR_DUSERID;

IF N_FLAG = 1 THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '用户已被禁止登录';
RETURN;
END IF;

--2.判断用户是否有兴趣tag

FOR REC_USERTAG IN CUR_USERTAG LOOP
INDEX_TAGS := TABLE_TAG();
IF CUR_USERTAG%ROWCOUNT = 0 THEN
--获取公共兴趣游标
FOR REC_USERPUB IN CUR_USERPUB LOOP
INDEX_TAGS.EXTEND;
IF CUR_USERPUB%ROWCOUNT = 1 THEN
VAR_FIRSTTAG := REC_USERPUB.TAGID;
END IF;
INDEX_TAGS(CUR_USERPUB%ROWCOUNT) := TAGS_INFO(REC_USERPUB.TAGID,
REC_USERPUB.NAME);
END LOOP;
ELSIF CUR_USERTAG%ROWCOUNT = 1 THEN
VAR_FIRSTTAG := REC_USERTAG.TAGID;
END IF;
INDEX_TAGS.EXTEND;
INDEX_TAGS(CUR_USERTAG%ROWCOUNT) := TAGS_INFO(REC_USERTAG.TAGID,
REC_USERTAG.NAME);
--index_tags(CUR_USERTAG%ROWCOUNT).TAGNAME := REC_USERTAG.NAME;

END LOOP;

IF INDEX_TAGS.COUNT <> 0 THEN
/* --3. 取出object
FOR REC_OBJ IN CUR_OBJ(VAR_FIRSTTAG) LOOP
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).OWNERID := REC_OBJ.OWNERID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).OBJECTID := REC_OBJ.OBJECTID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).DBUSID := REC_OBJ.DBUSID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).DUSERSID := REC_OBJ.DUSERSID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).TAGID := REC_OBJ.TAGID;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).LOVENUM := REC_OBJ.LOVENUM;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).INRUDUCTION := REC_OBJ.INRUDUCTION;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).CATAGROY := REC_OBJ.CATAGROY;
PRM_OBJECTS(CUR_OBJ%ROWCOUNT).Imagepath := REC_OBJ.Imagepath;

END LOOP;*/
--返回东西游标
OPEN PRM_OBJECTS FOR
SELECT ROWNUM AS RN, A.*, B.USERNAME
FROM OBJECT A, USERSDETIAL B
WHERE A.OWNERID = B.DUSERSID
AND TRIM(A.TAGID) = VAR_FIRSTTAG
AND ROWNUM < 30;

END IF;
--tag游标
OPEN PRM_TAGS FOR
SELECT * FROM TABLE(CAST(INDEX_TAGS AS TABLE_TAG));

EXCEPTION
WHEN OTHERS THEN
PRM_APPCODE := PKG_COMM.DEF_ERR;
PRM_ERRMSG := '获取主界面数据失败' || '错误原因:' || PRM_ERRMSG || '-' || SQLERRM ||
'错误行数:' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE();
END;
---注意:a.返回游标的用open for 方法,不用关心游标的关闭。它是自动关闭的。原因:调试把游标返回值点几下,你就回发现。
b.如果报错CURSOR IS CLOESD的话,说明游标里面没有数据。所以open for 必须保证有select中有数据
c.嵌套表这里要用类似与java的构造方法写,如上
如果写成类似于java中new对象后,用set方法给嵌套表赋值的,会报错未能未能初始化的结果集。

springmvc mybatis怎么实现分页查询

1.封装分页Page类

  package com.framework.common.page.impl;
  
  import java.io.Serializable;
  
  import com.framework.common.page.IPage;
  /**
  *
  *
  *
  */
  public abstract class BasePage implements IPage, Serializable {
  
  /**
  *
  */
  private static final long serialVersionUID = -3623448612757790359L;
  
  public static int DEFAULT_PAGE_SIZE = 20;
  private int pageSize = DEFAULT_PAGE_SIZE;
  private int currentResult;
  private int totalPage;
  private int currentPage = 1;
  private int totalCount = -1;
  
  public BasePage(int currentPage, int pageSize, int totalCount) {
  this.currentPage = currentPage;
  this.pageSize = pageSize;
  this.totalCount = totalCount;
  }
  
  public int getTotalCount() {
  return this.totalCount;
  }
  
  public void setTotalCount(int totalCount) {
  if (totalCount < 0) {
  this.totalCount = 0;
  return;
  }
  this.totalCount = totalCount;
  }
  
  public BasePage() {
  }
  
  public int getFirstResult() {
  return (this.currentPage - 1) * this.pageSize;
  }
  
  public void setPageSize(int pageSize) {
  if (pageSize < 0) {
  this.pageSize = DEFAULT_PAGE_SIZE;
  return;
  }
  this.pageSize = pageSize;
  }
  
  public int getTotalPage() {
  if (this.totalPage <= 0) {
  this.totalPage = (this.totalCount / this.pageSize);
  if ((this.totalPage == 0) || (this.totalCount % this.pageSize != 0)) {
  this.totalPage += 1;
  }
  }
  return this.totalPage;
  }
  
  public int getPageSize() {
  return this.pageSize;
  }
  
  public void setPageNo(int currentPage) {
  this.currentPage = currentPage;
  }
  
  public int getPageNo() {
  return this.currentPage;
  }
  
  public boolean isFirstPage() {
  return this.currentPage <= 1;
  }
  
  public boolean isLastPage() {
  return this.currentPage >= getTotalPage();
  }
  
  public int getNextPage() {
  if (isLastPage()) {
  return this.currentPage;
  }
  return this.currentPage + 1;
  }
  
  public int getCurrentResult() {
  this.currentResult = ((getPageNo() - 1) * getPageSize());
  if (this.currentResult < 0) {
  this.currentResult = 0;
  }
  return this.currentResult;
  }
  
  public int getPrePage() {
  if (isFirstPage()) {
  return this.currentPage;
  }
  return this.currentPage - 1;
  }
  
  
  }
  

  
  package com.framework.common.page.impl;
  
  import java.util.List;
  /**
  *
  *
  *
  */
  public class Page extends BasePage {
  
  /**
  *
  */
  private static final long serialVersionUID = -970177928709377315L;
  
  public static ThreadLocal<Page> threadLocal = new ThreadLocal<Page>();
  
  private List<?> data;
  
  public Page() {
  }
  
  public Page(int currentPage, int pageSize, int totalCount) {
  super(currentPage, pageSize, totalCount);
  }
  
  public Page(int currentPage, int pageSize, int totalCount, List<?> data) {
  super(currentPage, pageSize, totalCount);
  this.data = data;
  }
  
  public List<?> getData() {
  return data;
  }
  
  public void setData(List<?> data) {
  this.data = data;
  }
  
  
  }
  

  2.封装分页插件

  package com.framework.common.page.plugin;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.List;
  import java.util.Properties;
  
  import javax.xml.bind.PropertyException;
  
  import org.apache.commons.lang3.StringUtils;
  import org.apache.ibatis.executor.ErrorContext;
  import org.apache.ibatis.executor.ExecutorException;
  import org.apache.ibatis.executor.statement.BaseStatementHandler;
  import org.apache.ibatis.executor.statement.RoutingStatementHandler;
  import org.apache.ibatis.mapping.BoundSql;
  import org.apache.ibatis.mapping.MappedStatement;
  import org.apache.ibatis.mapping.ParameterMapping;
  import org.apache.ibatis.mapping.ParameterMode;
  import org.apache.ibatis.plugin.Interceptor;
  import org.apache.ibatis.plugin.Intercepts;
  import org.apache.ibatis.plugin.Invocation;
  import org.apache.ibatis.plugin.Plugin;
  import org.apache.ibatis.reflection.MetaObject;
  import org.apache.ibatis.reflection.property.PropertyTokenizer;
  import org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
  import org.apache.ibatis.session.Configuration;
  import org.apache.ibatis.type.TypeHandler;
  import org.apache.ibatis.type.TypeHandlerRegistry;
  
  import com.framework.common.page.impl.Page;
  import com.framework.common.utils.ReflectUtil;
  /**
  *
  *
  *
  */
  @Intercepts({ @org.apache.ibatis.plugin.Signature(type = org.apache.ibatis.executor.statement.StatementHandler.class, method = "prepare", args = { Connection.class }) })
  public class PagePlugin implements Interceptor {
  
  private String dialect = "";
  private String pageSqlId = "";
  
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
  if (invocation.getTarget() instanceof RoutingStatementHandler) {
  BaseStatementHandler delegate = (BaseStatementHandler) ReflectUtil
  .getValueByFieldName(
  (RoutingStatementHandler) invocation.getTarget(),
  "delegate");
  MappedStatement mappedStatement = (MappedStatement) ReflectUtil
  .getValueByFieldName(delegate,
  "mappedStatement");
  
  Page page = Page.threadLocal.get();
  if (page == null) {
  page = new Page();
  Page.threadLocal.set(page);
  }
  
  if (mappedStatement.getId().matches(".*(" + this.pageSqlId + ")$") && page.getPageSize() > 0) {
  BoundSql boundSql = delegate.getBoundSql();
  Object parameterObject = boundSql.getParameterObject();
  
  String sql = boundSql.getSql();
  String countSqlId = mappedStatement.getId().replaceAll(pageSqlId, "Count");
  MappedStatement countMappedStatement = null;
  if (mappedStatement.getConfiguration().hasStatement(countSqlId)) {
  countMappedStatement = mappedStatement.getConfiguration().getMappedStatement(countSqlId);
  }
  String countSql = null;
  if (countMappedStatement != null) {
  countSql = countMappedStatement.getBoundSql(parameterObject).getSql();
  } else {
  countSql = "SELECT COUNT(1) FROM (" + sql + ") T_COUNT";
  }
  
  int totalCount = 0;
  PreparedStatement countStmt = null;
  ResultSet resultSet = null;
  try {
  Connection connection = (Connection) invocation.getArgs()[0];
  countStmt = connection.prepareStatement(countSql);
  BoundSql countBoundSql = new BoundSql(mappedStatement.getConfiguration(), countSql, boundSql.getParameterMappings(), parameterObject);
  
  setParameters(countStmt, mappedStatement, countBoundSql, parameterObject);
  
  resultSet = countStmt.executeQuery();
  if(resultSet.next()) {
  totalCount = resultSet.getInt(1);
  }
  } catch (Exception e) {
  throw e;
  } finally {
  try {
  if (resultSet != null) {
  resultSet.close();
  }
  } finally {
  if (countStmt != null) {
  countStmt.close();
  }
  }
  }
  
  page.setTotalCount(totalCount);
  
  ReflectUtil.setValueByFieldName(boundSql, "sql", generatePageSql(sql,page));
  }
  }
  
  return invocation.proceed();
  }
  
  
  /**
  * 对SQL参数(?)设值,参考org.apache.ibatis.executor.parameter.DefaultParameterHandler
  * @param ps
  * @param mappedStatement
  * @param boundSql
  * @param parameterObject
  * @throws SQLException
  */
  private void setParameters(PreparedStatement ps,MappedStatement mappedStatement,BoundSql boundSql,Object parameterObject) throws SQLException {
  ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  if (parameterMappings != null) {
  Configuration configuration = mappedStatement.getConfiguration();
  TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  MetaObject metaObject = parameterObject == null ? null: configuration.newMetaObject(parameterObject);
  for (int i = 0; i < parameterMappings.size(); i++) {
  ParameterMapping parameterMapping = parameterMappings.get(i);
  if (parameterMapping.getMode() != ParameterMode.OUT) {
  Object value;
  String propertyName = parameterMapping.getProperty();
  PropertyTokenizer prop = new PropertyTokenizer(propertyName);
  if (parameterObject == null) {
  value = null;
  } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
  value = parameterObject;
  } else if (boundSql.hasAdditionalParameter(propertyName)) {
  value = boundSql.getAdditionalParameter(propertyName);
  } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX)&& boundSql.hasAdditionalParameter(prop.getName())) {
  value = boundSql.getAdditionalParameter(prop.getName());
  if (value != null) {
  value = configuration.newMetaObject(value).getValue(propertyName.substring(prop.getName().length()));
  }
  } else {
  value = metaObject == null ? null : metaObject.getValue(propertyName);
  }
  TypeHandler typeHandler = parameterMapping.getTypeHandler();
  if (typeHandler == null) {
  throw new ExecutorException("There was no TypeHandler found for parameter "+ propertyName + " of statement "+ mappedStatement.getId());
  }
  typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType());
  }
  }
  }
  }
  
  /**
  * 根据数据库方言,生成特定的分页sql
  * @param sql
  * @param page
  * @return
  */
  private String generatePageSql(String sql,Page page){
  if(page!=null && StringUtils.isNotBlank(dialect)){
  StringBuffer pageSql = new StringBuffer();
  if("mysql".equals(dialect)){
  pageSql.append(sql);
  pageSql.append(" LIMIT "+page.getCurrentResult()+","+page.getPageSize());
  }else if("oracle".equals(dialect)){
  pageSql.append("SELECT * FROM (SELECT TMP_TB.*,ROWNUM ROW_ID FROM (");
  pageSql.append(sql);
  pageSql.append(") AS TMP_TB WHERE ROWNUM <= ");
  pageSql.append(page.getCurrentResult()+page.getPageSize());
  pageSql.append(") WHERE ROW_ID > ");
  pageSql.append(page.getCurrentResult());
  }
  return pageSql.toString();
  }else{
  return sql;
  }
  }
  
  @Override
  public Object plugin(Object target) {
  return Plugin.wrap(target, this);
  }
  
  @Override
  public void setProperties(Properties properties) {
  try {
  if (StringUtils.isEmpty(this.dialect = properties
  .getProperty("dialect"))) {
  throw new PropertyException("dialect property is not found!");
  }
  if (StringUtils.isEmpty(this.pageSqlId = properties
  .getProperty("pageSqlId"))) {
  throw new PropertyException("pageSqlId property is not found!");
  }
  } catch (PropertyException e) {
  e.printStackTrace();
  }
  }
  
  }

附上出处链接:http://www.jb51.net/article/71829.htm
  

  

  

springmvc mybatis怎么实现分页查询

1.封装分页Page类

  package com.framework.common.page.impl;
  
  import java.io.Serializable;
  
  import com.framework.common.page.IPage;
  /**
  *
  *
  *
  */
  public abstract class BasePage implements IPage, Serializable {
  
  /**
  *
  */
  private static final long serialVersionUID = -3623448612757790359L;
  
  public static int DEFAULT_PAGE_SIZE = 20;
  private int pageSize = DEFAULT_PAGE_SIZE;
  private int currentResult;
  private int totalPage;
  private int currentPage = 1;
  private int totalCount = -1;
  
  public BasePage(int currentPage, int pageSize, int totalCount) {
  this.currentPage = currentPage;
  this.pageSize = pageSize;
  this.totalCount = totalCount;
  }
  
  public int getTotalCount() {
  return this.totalCount;
  }
  
  public void setTotalCount(int totalCount) {
  if (totalCount < 0) {
  this.totalCount = 0;
  return;
  }
  this.totalCount = totalCount;
  }
  
  public BasePage() {
  }
  
  public int getFirstResult() {
  return (this.currentPage - 1) * this.pageSize;
  }
  
  public void setPageSize(int pageSize) {
  if (pageSize < 0) {
  this.pageSize = DEFAULT_PAGE_SIZE;
  return;
  }
  this.pageSize = pageSize;
  }
  
  public int getTotalPage() {
  if (this.totalPage <= 0) {
  this.totalPage = (this.totalCount / this.pageSize);
  if ((this.totalPage == 0) || (this.totalCount % this.pageSize != 0)) {
  this.totalPage += 1;
  }
  }
  return this.totalPage;
  }
  
  public int getPageSize() {
  return this.pageSize;
  }
  
  public void setPageNo(int currentPage) {
  this.currentPage = currentPage;
  }
  
  public int getPageNo() {
  return this.currentPage;
  }
  
  public boolean isFirstPage() {
  return this.currentPage <= 1;
  }
  
  public boolean isLastPage() {
  return this.currentPage >= getTotalPage();
  }
  
  public int getNextPage() {
  if (isLastPage()) {
  return this.currentPage;
  }
  return this.currentPage + 1;
  }
  
  public int getCurrentResult() {
  this.currentResult = ((getPageNo() - 1) * getPageSize());
  if (this.currentResult < 0) {
  this.currentResult = 0;
  }
  return this.currentResult;
  }
  
  public int getPrePage() {
  if (isFirstPage()) {
  return this.currentPage;
  }
  return this.currentPage - 1;
  }
  
  
  }
  

  
  package com.framework.common.page.impl;
  
  import java.util.List;
  /**
  *
  *
  *
  */
  public class Page extends BasePage {
  
  /**
  *
  */
  private static final long serialVersionUID = -970177928709377315L;
  
  public static ThreadLocal<Page> threadLocal = new ThreadLocal<Page>();
  
  private List<?> data;
  
  public Page() {
  }
  
  public Page(int currentPage, int pageSize, int totalCount) {
  super(currentPage, pageSize, totalCount);
  }
  
  public Page(int currentPage, int pageSize, int totalCount, List<?> data) {
  super(currentPage, pageSize, totalCount);
  this.data = data;
  }
  
  public List<?> getData() {
  return data;
  }
  
  public void setData(List<?> data) {
  this.data = data;
  }
  
  
  }
  

  2.封装分页插件

  package com.framework.common.page.plugin;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.List;
  import java.util.Properties;
  
  import javax.xml.bind.PropertyException;
  
  import org.apache.commons.lang3.StringUtils;
  import org.apache.ibatis.executor.ErrorContext;
  import org.apache.ibatis.executor.ExecutorException;
  import org.apache.ibatis.executor.statement.BaseStatementHandler;
  import org.apache.ibatis.executor.statement.RoutingStatementHandler;
  import org.apache.ibatis.mapping.BoundSql;
  import org.apache.ibatis.mapping.MappedStatement;
  import org.apache.ibatis.mapping.ParameterMapping;
  import org.apache.ibatis.mapping.ParameterMode;
  import org.apache.ibatis.plugin.Interceptor;
  import org.apache.ibatis.plugin.Intercepts;
  import org.apache.ibatis.plugin.Invocation;
  import org.apache.ibatis.plugin.Plugin;
  import org.apache.ibatis.reflection.MetaObject;
  import org.apache.ibatis.reflection.property.PropertyTokenizer;
  import org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
  import org.apache.ibatis.session.Configuration;
  import org.apache.ibatis.type.TypeHandler;
  import org.apache.ibatis.type.TypeHandlerRegistry;
  
  import com.framework.common.page.impl.Page;
  import com.framework.common.utils.ReflectUtil;
  /**
  *
  *
  *
  */
  @Intercepts({ @org.apache.ibatis.plugin.Signature(type = org.apache.ibatis.executor.statement.StatementHandler.class, method = "prepare", args = { Connection.class }) })
  public class PagePlugin implements Interceptor {
  
  private String dialect = "";
  private String pageSqlId = "";
  
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
  if (invocation.getTarget() instanceof RoutingStatementHandler) {
  BaseStatementHandler delegate = (BaseStatementHandler) ReflectUtil
  .getValueByFieldName(
  (RoutingStatementHandler) invocation.getTarget(),
  "delegate");
  MappedStatement mappedStatement = (MappedStatement) ReflectUtil
  .getValueByFieldName(delegate,
  "mappedStatement");
  
  Page page = Page.threadLocal.get();
  if (page == null) {
  page = new Page();
  Page.threadLocal.set(page);
  }
  
  if (mappedStatement.getId().matches(".*(" + this.pageSqlId + ")$") && page.getPageSize() > 0) {
  BoundSql boundSql = delegate.getBoundSql();
  Object parameterObject = boundSql.getParameterObject();
  
  String sql = boundSql.getSql();
  String countSqlId = mappedStatement.getId().replaceAll(pageSqlId, "Count");
  MappedStatement countMappedStatement = null;
  if (mappedStatement.getConfiguration().hasStatement(countSqlId)) {
  countMappedStatement = mappedStatement.getConfiguration().getMappedStatement(countSqlId);
  }
  String countSql = null;
  if (countMappedStatement != null) {
  countSql = countMappedStatement.getBoundSql(parameterObject).getSql();
  } else {
  countSql = "SELECT COUNT(1) FROM (" + sql + ") T_COUNT";
  }
  
  int totalCount = 0;
  PreparedStatement countStmt = null;
  ResultSet resultSet = null;
  try {
  Connection connection = (Connection) invocation.getArgs()[0];
  countStmt = connection.prepareStatement(countSql);
  BoundSql countBoundSql = new BoundSql(mappedStatement.getConfiguration(), countSql, boundSql.getParameterMappings(), parameterObject);
  
  setParameters(countStmt, mappedStatement, countBoundSql, parameterObject);
  
  resultSet = countStmt.executeQuery();
  if(resultSet.next()) {
  totalCount = resultSet.getInt(1);
  }
  } catch (Exception e) {
  throw e;
  } finally {
  try {
  if (resultSet != null) {
  resultSet.close();
  }
  } finally {
  if (countStmt != null) {
  countStmt.close();
  }
  }
  }
  
  page.setTotalCount(totalCount);
  
  ReflectUtil.setValueByFieldName(boundSql, "sql", generatePageSql(sql,page));
  }
  }
  
  return invocation.proceed();
  }
  
  
  /**
  * 对SQL参数(?)设值,参考org.apache.ibatis.executor.parameter.DefaultParameterHandler
  * @param ps
  * @param mappedStatement
  * @param boundSql
  * @param parameterObject
  * @throws SQLException
  */
  private void setParameters(PreparedStatement ps,MappedStatement mappedStatement,BoundSql boundSql,Object parameterObject) throws SQLException {
  ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  if (parameterMappings != null) {
  Configuration configuration = mappedStatement.getConfiguration();
  TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
  MetaObject metaObject = parameterObject == null ? null: configuration.newMetaObject(parameterObject);
  for (int i = 0; i < parameterMappings.size(); i++) {
  ParameterMapping parameterMapping = parameterMappings.get(i);
  if (parameterMapping.getMode() != ParameterMode.OUT) {
  Object value;
  String propertyName = parameterMapping.getProperty();
  PropertyTokenizer prop = new PropertyTokenizer(propertyName);
  if (parameterObject == null) {
  value = null;
  } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
  value = parameterObject;
  } else if (boundSql.hasAdditionalParameter(propertyName)) {
  value = boundSql.getAdditionalParameter(propertyName);
  } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX)&& boundSql.hasAdditionalParameter(prop.getName())) {
  value = boundSql.getAdditionalParameter(prop.getName());
  if (value != null) {
  value = configuration.newMetaObject(value).getValue(propertyName.substring(prop.getName().length()));
  }
  } else {
  value = metaObject == null ? null : metaObject.getValue(propertyName);
  }
  TypeHandler typeHandler = parameterMapping.getTypeHandler();
  if (typeHandler == null) {
  throw new ExecutorException("There was no TypeHandler found for parameter "+ propertyName + " of statement "+ mappedStatement.getId());
  }
  typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType());
  }
  }
  }
  }
  
  /**
  * 根据数据库方言,生成特定的分页sql
  * @param sql
  * @param page
  * @return
  */
  private String generatePageSql(String sql,Page page){
  if(page!=null && StringUtils.isNotBlank(dialect)){
  StringBuffer pageSql = new StringBuffer();
  if("mysql".equals(dialect)){
  pageSql.append(sql);
  pageSql.append(" LIMIT "+page.getCurrentResult()+","+page.getPageSize());
  }else if("oracle".equals(dialect)){
  pageSql.append("SELECT * FROM (SELECT TMP_TB.*,ROWNUM ROW_ID FROM (");
  pageSql.append(sql);
  pageSql.append(") AS TMP_TB WHERE ROWNUM <= ");
  pageSql.append(page.getCurrentResult()+page.getPageSize());
  pageSql.append(") WHERE ROW_ID > ");
  pageSql.append(page.getCurrentResult());
  }
  return pageSql.toString();
  }else{
  return sql;
  }
  }
  
  @Override
  public Object plugin(Object target) {
  return Plugin.wrap(target, this);
  }
  
  @Override
  public void setProperties(Properties properties) {
  try {
  if (StringUtils.isEmpty(this.dialect = properties
  .getProperty("dialect"))) {
  throw new PropertyException("dialect property is not found!");
  }
  if (StringUtils.isEmpty(this.pageSqlId = properties
  .getProperty("pageSqlId"))) {
  throw new PropertyException("pageSqlId property is not found!");
  }
  } catch (PropertyException e) {
  e.printStackTrace();
  }
  }
  
  }

附上出处链接:http://www.jb51.net/article/71829.htm
  

  

  

CCS 3.3 在运行时报错Power Failure on Target CPU: Error 0x80000020/-1031 Fatal Error during:

1. 提示错误:Trouble Setting Breakpoint with the Action "Halt Target" at 0x3ec3bf: Error 0x0000000A/-2140 Error ring: Memory, Break Point, Cannot access memory address at 0x00000800 Sequence ID: 7 Error Code: -2140 Error Class: 0x0000000A 设置硬件断点的方法:

debug---breakpoints 在弹出的对话框中 在breakpoint 下拉框中选H/W break/////

但是必须要有硬件,我试过了,没有硬件的情况下是没有的,没有联上硬件的情况下是不能选择的

如果第一次能够启动CCS,但接下来得到CCS不能初始化目标系统DSP的出错信息则可选择Debug→Reset DSP菜单项。若还不能解决上述问题,你可能需要运行你的目标板所提供的复位程序。

我的工程在CCS3.3版本下不能设置断点,在CCS2.2版本下可以设置断点,是什么原因?

我用合众达的XDS100仿真器和CCS3.3软件,可以给F2808的板子下载程序,但是不能设置断点。 相同的程序在CCS2.2版本下可以设置断点。请问是怎么回事?

答:在ccs3.3环境下,程序在FLASH中调试。不能设置断点。因为系统默认会设置两个断点。这样在程序段中就不能设置断点了。

通过设置,CCS3.3中的选中Option中的Customize。接着选中Program/Project/CIO,子菜单中勾选Do Not Set CIO Breakpoint AT……和Do Not Set End of Program Breakpoint AT……。点击确定即可。 即可在flash中调试设置两个断点了。

2 error: system error, can't open file

'E:\DSP\DSP\sprc100\DSP281x_examples\kalman-zhangna01\Debug\kalman_na.obj' for input: No such file or directory。

原因:误点了 project中的build options 中的diagnostics 中的输出_err文件。使得文件中的错误以.err文件的形式输出,而这个文件又打不开,使得错误的文件不能调试,也不能输出.obj文件。

3. line 189: error: expected a ")"

内容为: MatrixInver(m0[4][1],MatrixInver_m00[1][4]4,1); 其实是少了个 “ ,” MatrixInver(m0[4][1],MatrixInver_m00[1][4],4,1); 4. identifier "n" is undefined; identifier "m" is undefined

内容为:Matrix_DEL(float A[],float B[],float C[], n, m)

应改为:Matrix_DEL(float A[],float B[],float C[], int n, int m)

5 2010-9-15 调试串口程序,SCIFFTX及SCIFFRX总是显示有中断,那就说明是有数据到来的,我们的程序是之前调好的,应该没有问题,所以可能是硬件的问题。后来想起,串口A在之前拉飞线时搞坏了,换了B口改了程序,一直不好,用示波器量有数据从IMU发送,研究了好久发现程序有问题,有一个需要将A改为B的地方没有改,就是SCIBSBUF中的。

6 "malloc.h", line 23: fatal error: #error ERROR: Only Mac or Win32 targets supported!

在子函数中加入此头文件就会提示此错误,在主函数中加入此头文件,并且在项目中加入就不会提示此错误。并且在使用时,需要在主函数和子函数中添加头文件#include "stdlib.h"。

7 在矩阵求逆程序MatrixOpp_xm.c中,数据总是算不对。

当测试数据位2*2的矩阵是,程序就能算对,当测试数据为4*4时,就算不对,表现为,指针is和js乱指一气,指向了非法的地址空间。

在网上搜到的资料:杜绝“野指针” “野指针”不是NULL 指针,是指向“垃圾”内存的指针。人们一般不会错用NULL 指针,因为用if 语句很容易判断。但是“野指针”是很危险的,if 语句对它不起作用。

“野指针”的成因主要有两种:

(1)指针变量没有被初始化。任何指针变量刚被创建时不会自动成为NULL 指针,它

的缺省值是随机的,它会乱指一气。所以,指针变量在创建的同时应当被初始化,要么

将指针设置为NULL,要么让它指向合法的内存。例如 char *p = NULL;

char *str = (char *) malloc(100);

(2)指针p 被free或者delete之后,没有置为NULL,让人误以为p 是个合法的指针。

(3)指针操作超越了变量的作用范围。

于是在程序中将is和js首先赋值 int *is=NULL;int *js=NULL;此时需要加头文件#include "stdlib.h",编译就正确了。

8 问题:在高斯牛顿迭代是,欲迭代十次,因此定义了一个迭代次数变量k_times,但是在运行中间,在进行某个子函数结束返回时,k_times的值被莫名其妙的改变了,因而造成无法正常循环。

原因:k_times是高斯牛顿函数内定义的一个局部变量,因此它的地址是动态分配的,在运行中改变可能是,由于在运行中某个变量占用了,它正在使用的存储地址,因而造成变量一下突然改变又被清零了。

方法:将k_times定义成为一个静态变量stastic,使它所占用的存储空间是不变的,就可以了。但是需要注意,当使用stastic时,该存储空间的内容是不变的,因此当一个十次循环结束,再一次重新进入此循环时,该存储空间存放的k_times的值是上次叠加到的值10。因此必须每次将该值清零,重新叠加。 9 黑莓仿真器无法连接 首先拔掉仿真器和电源,重新启动,如果还是出现相同问题,进入我的电脑,属性中选择硬件,点击设备管理器,找到黑莓。更新驱动程序,选择和CCS3.3同一目录下的方针驱动程序进行安装。如还不行,卸掉驱动软件,插上USB重新检测新硬件,重新更新驱动,根据提示,找东西。目录中有两个方针驱动的安装环境,看清。

10 sin cos函数无法调用,提示找不到这两个函数 应加头文件#include “stdio.h”

11 "kalman_extend.c", line 419: error: argument of type "float (*)[6]" is incompatible with parameter of type "float *"

改成MatrixInver(float A[][],float B[][], int n, int m) 报新错

../head/Matrix_math.h", line 140: error: an array may not have elements of this type

12 Can't Run Target CPU: Error 0x00000020/-1150 Error ring: Execution, JTAG protocol reset.

需要更新ccs的烧写插件 及烧写函数库 这个你可以跟就进的办事处要

HCF4013B这个芯片是干什么用的

双D触发器,以下为英文资料复制,希望对你有帮助:)

n SET - RESET CAPABILITY

n STATIC FLIP-FLOP OPERATION - RETAINS

STATE INDEFINITELY WITH CLOCK LEVEL

EITHER "HIGH" OR "LOW"

n MEDIUM SPEED OPERATION 16MHz (TYP.)

CLOCK TOGGLE RATE AT 10V

n STANDARDIZED SYMMETRICAL OUTPUT

CHARACTERISTICS

n QUIESCENT CURRENT SPECIFIED UP TO

20V

n 5V, 10V AND 15V PARAMETRIC RATINGS

n INPUT LEAKAGE CURRENT

II = 100nA (MAX) AT VDD = 18V TA = 25°C

n 100% TESTED FOR QUIESCENT CURRENT

n MEETS ALL REQUIREMENTS OF JEDEC

JESD13B " STANDARD SPECIFICATIONS

FOR DESCRIPTION OF B SERIES CMOS

DEVICES"

DESCRIPTION

The HCF4013B is a monolithic integrated circuit

fabricated in Metal Oxide Semiconctor

technology available in DIP and SOP packages.

The HCF4013B consists of two identical,

independent data type flip-flops. Each flip-flop has

independent data, set, reset, and clock inputs and

Q and Q outputs. This device can be used for shift

register applications, and, by connecting Q output

to the data input, for counter and toggle

applications. The logic level present at the D input

is transferred to the Q output ring the

positive-going transition of the clock pulse. Setting

or resetting is independent of the clock and is

accomplished by a high level on the set or reset

line, respectively

HCF4013B

DUAL D-TYPE FLIP FLOP

PIN CONNECTION

ORDER CODES

PACKAGE TUBE T & R

DIP HCF4013BEY

SOP HCF4013BM1 HCF4013M013TR

DIP SOP

HCF4013B

2/9

INPUT EQUIVALENT CIRCUIT

LOGIC DIAGRAM

PIN DESCRIPTION

TRUTH TABLE

X : Don’t Care

D : Low Level

ABSOLUTE MAXIMUM RATINGS

Absolute Maximum Ratings are those values beyond which damage to the device may occur. Functional operation under these conditions is

not implied.

All voltage values are referred to VSS pin voltage.

RECOMMENDED OPERATING CONDITIONS

PIN No SYMBOL NAME AND FUNCTION

3, 11 CLOCK1

CLOCK2

Clock Inputs

4, 10

RESET1

RESET2

Reset Inputs

6, 8 SET1, SET2 Set Inputs

5, 9 D1, D2 Data Inputs

1, 13 Q1, Q2 Data Outputs

2, 12 Q1, Q2 Data Outputs

7 VSS Negative Supply Voltage

14 VDD Positive Supply Voltage

CLOCKD D RESET SET Q Q

L L L L H

H L L H L

X L L Q Q

X X H L L H

X X L H H L

X X H H H H

Symbol Parameter Value Unit

VDD Supply Voltage -0.5 to +22 V

VI DC Input Voltage -0.5 to VDD + 0.5 V

II DC Input Current ± 10 mA

PD Power Dissipation per Package 200 mW

Power Dissipation per Output Transistor 100 mW

Top Operating Temperature -55 to +125 °C

Tstg Storage Temperature -65 to +150 °C

Symbol Parameter Value Unit

VDD Supply Voltage 3 to 20 V

VI Input Voltage 0 to VDD V

Top Operating Temperature -55 to 125 °C

HCF4013B

3/9

DC SPECIFICATIONS

The Noise Margin for both "1" and "0" level is: 1V min. with VDD=5V, 2V min. with VDD=10V, 2.5V min. with VDD=15V

Symbol Parameter

Test Condition Value

Unit VI

(V)

VO

(V)

|IO|

(mA)

VDD

(V)

TA = 25°C -40 to 85°C -55 to 125°C

Min. Typ. Max. Min. Max. Min. Max.

IL Quiescent Current 0/5 5 0.02 1 30 30

mA

0/10 10 0.02 2 60 60

0/15 15 0.02 4 120 120

0/20 20 0.04 20 600 600

VOH High Level Output

Voltage

0/5 <1 5 4.95 4.95 4.95

V 0/10 <1 10 9.95 9.95 9.95

0/15 <1 15 14.95 14.95 14.95

VOL Low Level Output

Voltage

5/0 <1 5 0.05 0.05 0.05

V 10/0 <1 10 0.05 0.05 0.05

15/0 <1 15 0.05 0.05 0.05

VIH High Level Input

Voltage

0.5/4.5 <1 5 3.5 3.5 3.5

V 1/9 <1 10 7 7 7

1.5/13.5 <1 15 11 11 11

VIL Low Level Input

Voltage

4.5/0.5 <1 5 1.5 1.5 1.5

V 9/1 <1 10 3 3 3

13.5/1.5 <1 15 4 4 4

IOH Output Drive

Current

0/5 2.5 <1 5 -1.36 -3.2 -1.15 -1.1

mA

0/5 4.6 <1 5 -0.44 -1 -0.36 -0.36

0/10 9.5 <1 10 -1.1 -2.6 -0.9 -0.9

0/15 13.5 <1 15 -3.0 -6.8 -2.4 -2.4

IOL Output Sink

Current

0/5 0.4 <1 5 0.44 1 0.36 0.36

mA 0/10 0.5 <1 10 1.1 2.6 0.9 0.9

0/15 1.5 <1 15 3.0 6.8 2.4 2.4

II Input Leakage

Current

0/18 Any Input 18 ±10-5 ±0.1 ±1 ±1 mA

CI Input Capacitance Any Input 5 7.5 pF

HCF4013B

4/9

DYNAMIC ELECTRICAL CHARACTERISTICS (Tamb = 25°C, CL = 50pF, RL = 200KW, tr = tf = 20 ns)

(*) Typical temperature coefficient for all VDD value is 0.3 %/°C.

(1) Input tr, tf = 5ns

(2) If more than unit is cascaded in a parallel clocked application, tr should be made less than or equal to the sum of the fixed propagation

delay time at 15pF and the transition time of the carry output driving stage for the estimated capacitive load.

Symbol Parameter

Test Condition Value (*) Unit

VDD (V) Min. Typ. Max.

tTLH tTHL Propagation Delay Time

(CLOCK to Q or Q outputs)

5 150 300

ns 10 65 130

15 45 90

tPLH Propagation Delay Time

(SET to Q or RESET to Q)

5 150 300

ns 10 65 130

15 45 90

tPHL Propagation Delay

Time(SET to Q or RESET

to Q)

5 200 400

ns 10 85 170

15 60 120

tTHL tTLH Transition Time 5 100 200

ns 10 50 100

15 40 80

fCL

(1) Maximum Clock Input

Frequency

5 3.5 7

MHz 10 8 16

15 12 24

tW Clock Pulse Width 5 140 70

ns 10 60 30

15 40 20

tr , tf

(2) Clock Input Rise or Fall

Time

5 15

ms 10 4

15 1

tW Set or Reset Pulse Width 5 180 90

ns 10 80 40

15 50 25

tsetup Data Setup Time 5 40 20

ns 10 20 10

15 15 7

HCF4013B

5/9

TEST CIRCUIT

CL = 50pF or equivalent (includes jig and probe capacitance)

RL = 200KW

RT = ZOUT of pulse generator (typically 50W)

WAVEFORM 1 : CLOCK TO Qn, Qn PROPAGATION DELAY TIMES, Dn TO CLOCK SETUP AND

HOLD TIMES, CLOCK MINIMUM PULSE WITDH, MAXIMUM CLOCK FREQUENCY

(f=1MHz; 50% ty cycle)

HCF4013B

6/9

WAVEFORM 2 : PROPAGATION DELAY TIMES (Qn, Qn TO SET, RESET), MINIMUM PULSE WIDTH

(SET AND RESET) (f=1MHz; 50% ty cycle)

HCF4013B

7/9

DIM.

mm. inch

MIN. TYP MAX. MIN. TYP. MAX.

a1 0.51 0.020

B 1.39 1.65 0.055 0.065

b 0.5 0.020

b1 0.25 0.010

D 20 0.787

E 8.5 0.335

e 2.54 0.100

e3 15.24 0.600

F 7.1 0.280

I 5.1 0.201

L 3.3 0.130

Z 1.27 2.54 0.050 0.100

Plastic DIP-14 MECHANICAL DATA

P001A

HCF4013B

8/9

DIM.

mm. inch

MIN. TYP MAX. MIN. TYP. MAX.

A 1.75 0.068

a1 0.1 0.2 0.003 0.007

a2 1.65 0.064

b 0.35 0.46 0.013 0.018

b1 0.19 0.25 0.007 0.010

C 0.5 0.019

c1 45° (typ.)

D 8.55 8.75 0.336 0.344

E 5.8 6.2 0.228 0.244

e 1.27 0.050

e3 7.62 0.300

F 3.8 4.0 0.149 0.157

G 4.6 5.3 0.181 0.208

L 0.5 1.27 0.019 0.050

M 0.68 0.026

S 8° (max.)

SO-14 MECHANICAL DATA

PO13G

HCF4013B

Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the

consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from

its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications

mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information

previously supplied. STMicroelectronics procts are not authorized for use as critical components in life support devices or

systems without express written approval of STMicroelectronics.

© The ST logo is a registered trademark of STMicroelectronics

© 2001 STMicroelectronics - Printed in Italy - All Rights Reserved

STMicroelectronics GROUP OF COMPANIES

Australia - Brazil - China - Finland - France - Germany - Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco

Singapore - Spain - Sweden - Switzerland - United Kingdom

© http://www.st.com

9/9

补充:

1.锁相环里有类似的一个功能,将频率转化成电压,再通过压控振荡器控制频

2.多用电荷泵代阻容负载实现

我知道的也只有这些了,呵呵。

Top