易截截图软件、单文件、免安装、纯绿色、仅160KB

通过ibatis的blob 存储java的hashmap

 这几天测试blob获取和存储的时候,被卡了很久,最后才发现是占用了关键字导致无法获取结果,血的教训啊.
以后起名字要用最恶心的,不要用最方便的了.闲话少说,java的hashmap是不能直接存储到数据库中的.
本地数据库为mysql,里面有blob的类型可供使用.方法也很简单,上代码
数据库建表
CREATE TABLE `test` (
`id` varchar(32) NOT NULL,
`fieldarr` blob,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Java类
public class Test implements Serializable{
private String id;
private byte[] fields;
public String getId(){
return id;
}
public void setId(String id){
this.id = id;
}
public byte[] getFields(){
return fields;
}
public void setFields(byte[] fields){
this.fields = fields;
}
}

然后配置ibatis
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Test">
<!-- Use type aliases to avoid typing the full classname every time. -->
<typeAlias alias="Test" type="bruce.Test"/>
<resultMap id="FieldResult" class="Test">
<result property="id" column="ID"/>
<result property="fields" column="FIELDARR" jdbcType="BLOB" />
</resultMap>
<select id="selectTestByid" parameterClass="string" resultMap="FieldResult">
<!--[CDATA[
select * from test
where ID = #value#
]]>
</select>
<update id="updateTest" parameterClass="Test">
<![CDATA[
update test set
FIELDARR = #fields#
where
ID = #id#
]]-->
</update>

</sqlMap>

dao正常写就可以
public List<Test> selectTestByid(String id) throws SQLException {


相关文档:

关于 java swing 中的repaint 和 revalidate 含义

   repaint 对组件进行重绘,比如一个panel,当你remove掉panel里面的一个组件时,你必须调用repaint方法才能对panel进行重绘,进行刷新,你想要删除的组件才能在界面上消失。
   revalidate 对组件进行验证,比如一个panel,当你remove掉panel里面的一个组件时,当你调用revalidate方法后,panel的布 ......

java中synchronized用法

synchronized的一个简单例子
public class TextThread
{
 /**
  * @param args
  */
 public static void main(String[] args)
 {
  // TODO 自动生成方法存根
        TxtThread tt = new TxtThread();
      ......

java获取程序当前目录。

import java.net.URL;
import java.net.URLDecoder;
public class PathUtil
{
 /**
  * Get the env of windir, such as "C:\WINDOWS".
  * @return the env of windir value.
  */
 public static String getWindir(){
  return System.getenv("windir");
 }
 
......

java 访问。net webservice

java访问。net的webservice 而且 返回值是一个类,这玩意折磨我一天,出现过一系列的问题,
包括 没有定义SoapAction 不能序列化类等等。 最后还是服务提供商给了个demo,解决了 ,原因是我返回自定义类的一个变量没有get函数,可耻啊。而且demo里的代码 我想也是用wsdd2java生成的,我以前也看到过这种模式的实现,看着费 ......

2年java购物车分析

一.点击图书,展示该书的详细信息
 点击图书→books页面→通过url重写displayBook.jsp?isbn=该书编号 →传入displayBooks页面→
<c:set var="isbn" value="${param.isbn}"></c:set>
<c:forEach var="currentBook" items="${sessionScope.bookTitles}">
 <c:if test="${ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号