自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(2)
  • 资源 (22)
  • 收藏
  • 关注

原创 mysql的安装出现”错误 1067: 进程意外终止”问题的最终解决方案

mysql 错误 1067: 进程意外终止  只要你的my.ini文件配置好了,再出现1067错误的话那一般就是你的my.ini文件没有 放到c:\windows目录下只要将my.ini文件剪切到到系统windows目录下,启动服务,ok!!!

2016-04-23 00:55:55 331

转载 python模块介绍-httplib:HTTP协议客户端和HTTPS协议客户端

python模块介绍-httplib:HTTP协议客户端 注意:httplib模块在Python3.0中已更名为http.client。2to3脚本会自动修改import当你的源代码转换时到3.0时。httplib实现了HTTP和HTTPS的客户端协议,一般不直接使用,在python更高层的封装模块中(urllib,urllib2)使用了它的HTTP和HTTPS实现。其中HTTPS

2015-10-27 09:26:00 3886

tong46安装

tong46安装方案,适合接触tong中间件的同学参考

2015-12-24

本地虚拟机安装CentOS报错 解决方案

加载CentOS的ISO文件开始安装时,安装文件要求检测I/O设备,选“skip”后,本应进入安装程序的图形界面,但是却报错误

2015-12-24

vnware服务器搭建步骤

vnware服务器搭建详细步骤,适合初学者学习参考

2015-12-24

Linux服务器scp无密码传输文件操作说明

Linux服务器scp无密码传输文件操作说明

2015-12-24

windows7的python环境搭建手册.doc

win7环境下python开发环境的搭建步骤及可能会发生的问题的处理,有助于刚接触python开发的童鞋参考学习

2015-12-24

Grid++ Report报表与票据套打开发步骤

grid++ 流行报表打印 全能报表打印 连打套打打印 完美打印工具

2015-12-24

centos6.3版本的安装于配置

主要是针对配置centos6.3版本的安装、python26的安装、python26模块的安装、nginx服务的安装、hg安装、解决乱码问题及ftp问题,centos6.3版本的安装与配置,安装过程中的配置,安装包选择

2015-12-24

java编码开发规范

本文档记述了JAVA开发中的有关包、类、抽象类、接口、方法、变量和常量的命名规则,用于规范JAVA编码过程中的命名和代码书写规范。

2015-12-24

hg使用规范及方法

hg版本库控制的规范及使用方法,方便代码及文档的统一管理及使用更新

2015-12-24

python3的http应用

针对python3与python2中http创建链接的方式时引用模块的改变的应用 https

2015-10-27

python3的http及https应用

针对python3与python2中http创建链接的方式时引用模块的改变的应用

2015-10-27

字符编码:GBK、GB2312、UTF-8

一、各编码间的区别及故事来历 UTF-8:Unicode TransformationFormat-8bit,允许含BOM,但通常不含BOM。是用以解决国际上字符的一种多字节编码,它对英文使用8位(即一个字节),中文使用24为(三个字节)来编码。UTF-8包含全世界所有国家需要用到的字符,是国际编码,通用性强。UTF-8编码的文字可以在各国支持UTF8字符集的浏览器上显示。如,如果是UTF8编码,则在外国人的英文IE上也能显示中文,他们无需下载IE的中文语言支持包。

2014-09-29

什么是NoSQL数据库?

关系型数据库和NoSQL数据库 什么是NoSQL 大家有没有听说过“NoSQL”呢?近年,这个词极受关注。看到“NoSQL”这个词,大家可能会误以为是“No!SQL”的缩写,并深感愤怒:“SQL怎么会没有必要了呢?”但实际上,它是“Not Only SQL”的缩写。它的意义是:适用关系型数据库的时候就使用关系型数据库,不适用的时候也没有必要非使用关系型数据库不可,可以考虑使用更加合适的数据存储。 为弥补关系型数据库的不足,各种各样的NoSQL数据库应运而生。 为了更好地了解本书所介绍的NoSQL数据库,对关系型数据库的理解是必不可少的。那么,就让我们先来看一看关系型数据库的历史、分类和特征吧。 关系型数据库简史 1969年,埃德加•弗兰克•科德(Edgar Frank Codd)发表了划时代的论文,首次提出了关系数据模型的概念。但可惜的是,刊登论文的《IBM Research Report》只是IBM公司的内部刊物,因此论文反响平平。1970年,他再次在刊物《Communication of the ACM》上发表了题为“A Relational Model of Data for Large Shared Data banks”(大型共享数据库的关系模型)的论文,终于引起了大家的关注。 科德所提出的关系数据模型的概念成为了现今关系型数据库的基础。当时的关系型数据库由于硬件性能低劣、处理速度过慢而迟迟没有得到实际应用。但之后随着硬件性能的提升,加之使用简单、性能优越等优点,关系型数据库得到了广泛的应用。 通用性及高性能 虽然本书是讲解NoSQL数据库的,但有一个重要的大前提,请大家一定不要误解。这个大前提就是“关系型数据库的性能绝对不低,它具有非常好的通用性和非常高的性能”。毫无疑问,对于绝大多数的应用来说它都是最有效的解决方案。 突出的优势 关系型数据库作为应用广泛的通用型数据库,它的突出优势主要有以下几点: 保持数据的一致性(事务处理) 由于以标准化为前提,数据更新的开销很小(相同的字段基本上都只有一处) 可以进行JOIN等复杂查询 存在很多实际成果和专业技术信息(成熟的技术) 这其中,能够保持数据的一致性是关系型数据库的最大优势。在需要严格保证数据一致性和处理完整性的情况下,用关系型数据库是肯定没有错的。但是有些情况不需要JOIN,对上述关系型数据库的优点也没有什么特别需要,这时似乎也就没有必要拘泥于关系型数据库了。 关系型数据库的不足 不擅长的处理 就像之前提到的那样,关系型数据库的性能非常高。但是它毕竟是一个通用型的数据库,并不能完全适应所有的用途。具体来说它并不擅长以下处理: 大量数据的写入处理 为有数据更新的表做索引或表结构(schema)变更 字段不固定时应用 对简单查询需要快速返回结果的处理 。。。。。。 NoSQL数据库 为了弥补关系型数据库的不足(特别是最近几年),NoSQL数据库出现了。关系型数据库应用广泛,能进行事务处理和JOIN等复杂处理。相对地,NoSQL数据库只应用在特定领域,基本上不进行复杂的处理,但它恰恰弥补了之前所列举的关系型数据库的不足之处。 易于数据的分散 如前所述,关系型数据库并不擅长大量数据的写入处理。原本关系型数据库就是以JOIN为前提的,就是说,各个数据之间存在关联是关系型数据库得名的主要原因。为了进行JOIN处理,关系型数据库不得不把数据存储在同一个服务器内,这不利于数据的分散。相反,NoSQL数据库原本就不支持JOIN处理,各个数据都是独立设计的,很容易把数据分散到多个服务器上。由于数据被分散到了多个服务器上,减少了每个服务器上的数据量,即使要进行大量数据的写入操作,处理起来也更加容易。同理,数据的读入操作当然也同样容易。 提升性能和增大规模 下面说一点题外话,如果想要使服务器能够轻松地处理更大量的数据,那么只有两个选择:一是提升性能,二是增大规模。下面我们来整理一下这两者的不同。 首先,提升性能指的就是通过提升现行服务器自身的性能来提高处理能力。这是非常简单的方法,程序方面也不需要进行变更,但需要一些费用。若要购买性能翻倍的服务器,需要花费的资金往往不只是原来的2倍,可能需要多达5到10倍。这种方法虽然简单,但是成本较高。 另一方面,增大规模指的是使用多台廉价的服务器来提高处理能力。它需要对程序进行变更,但由于使用廉价的服务器,可以控制成本。另外,以后只要依葫芦画瓢增加廉价服务器的数量就可以了。 不对大量数据进行处理的话就没有使用的必要吗? NoSQL数据库基本上来说为了“使大量数据的写入处理更加容易(让增加服务器数量更容易)”而设计的。但如果不是对大量数据进行操作的话,NoSQ

2014-07-21

javascript 基于正则表达式的文本框验证代码

1,不能为空 <input type="text" +| +$/g,'')=='')alert('不能为空!')"> 2,只能输入英文和数字 <input <input <input type="text" 3,判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母 /^([a-zA-z_]{1})([\w]*)$/g.test(str) 4,只能输入数字 <input name="text" type="text" id="NewPage" > 5,只能输入中文 <input type="text" 6,只能输入英文 <input type="text" <input type="text" 7,只能输入中文、英文、数字、@符号和.符号 <input type="text" 8,只允许输入英文,且不能粘贴也无法弹出粘贴菜单 <input type="text" false" false"/> 只能输入数字和点号(注意:在[^\d\.]里的d不能写成大写D,否则就变成除了数字以外的所有字符) <input name="price" type="text" size="8" maxlength="8" > 总而言之:先在<input>里输入onkeyup="value=value.replace(/[^\\X]/g,'')" 然后在(/[\X]/g,'')里的X换成你想输入的代码就可以了

2013-01-24

把图片做成input提交按钮

<input type="submit" id="submit" align="right" width="80" height="40" url(<%=path %>/img/confirmorder/submitbtn.gif)" />

2013-01-24

MD5Code加密技术

public class MD5Code { static final int S11 = 7; static final int S12 = 12; static final int S13 = 17; static final int S14 = 22; static final int S21 = 5; static final int S22 = 9; static final int S23 = 14; static final int S24 = 20; static final int S31 = 4; static final int S32 = 11; static final int S33 = 16; static final int S34 = 23; static final int S41 = 6; static final int S42 = 10; static final int S43 = 15; static final int S44 = 21; static final byte[] PADDING = { -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; private long[] state = new long[4];// state (ABCD) private long[] count = new long[2];// number of bits, modulo 2^64 (lsb // first) private byte[] buffer = new byte[64]; // input buffer /* * digestHexStr是MD5的唯一一个公共成员,是最新一次计算结果的 16进制ASCII表示. */ public String digestHexStr; /* * digest,是最新一次计算结果的2进制内部表示,表示128bit的MD5值. */ private byte[] digest = new byte[16]; /* * getMD5ofStr是类MD5最主要的公共方法,入口参数是你想要进行MD5变换的字符串 * 返回的是变换完的结果,这个结果是从公共成员digestHexStr取得的. */ public String getMD5ofStr(String inbuf) { md5Init(); md5Update(inbuf.getBytes(), inbuf.length()); md5Final(); digestHexStr = ""; for (int i = 0; i < 16; i++) { digestHexStr += byteHEX(digest[i]); } return digestHexStr; } // 这是MD5这个类的标准构造函数,JavaBean要求有一个public的并且没有参数的构造函数 public MD5Code() { md5Init(); return; } /* md5Init是一个初始化函数,初始化核心变量,装入标准的幻数 */ private void md5Init() { count[0] = 0L; count[1] = 0L; // /* Load magic initialization constants. state[0] = 0x67452301L; state[1] = 0xefcdab89L; state[2] = 0x98badcfeL; state[3] = 0x10325476L; return; } /* * F, G, H ,I 是4个基本的MD5函数,在原始的MD5的C实现中,由于它们是 * 简单的位运算,可能出于效率的考虑把它们实现成了宏,在java中,我们把它们 实现成了private方法,名字保持了原来C中的。 */ private long F(long x, long y, long z) { return (x & y) | ((~x) & z); } private long G(long x, long y, long z) { return (x & z) | (y & (~z)); } private long H(long x, long y, long z) { return x ^ y ^ z; } private long I(long x, long y, long z) { return y ^ (x | (~z)); } /* * FF,GG,HH和II将调用F,G,H,I进行近一步变换 FF, GG, HH, and II transformations for * rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent * recomputation. */ private long FF(long a, long b, long c, long d, long x, long s, long ac) { a += F(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long GG(long a, long b, long c, long d, long x, long s, long ac) { a += G(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long HH(long a, long b, long c, long d, long x, long s, long ac) { a += H(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } private long II(long a, long b, long c, long d, long x, long s, long ac) { a += I(b, c, d) + x + ac; a = ((int) a << s) | ((int) a >>> (32 - s)); a += b; return a; } /* * md5Update是MD5的主计算过程,inbuf是要变换的字节串,inputlen是长度,这个 * 函数由getMD5ofStr调用,调用之前需要调用md5init,因此把它设计成private的 */ private void md5Update(byte[] inbuf, int inputLen) { int i, index, partLen; byte[] block = new byte[64]; index = (int) (count[0] >>> 3) & 0x3F; // /* Update number of bits */ if ((count[0] += (inputLen << 3)) < (inputLen << 3)) count[1]++; count[1] += (inputLen >>> 29); partLen = 64 - index; // Transform as many times as possible. if (inputLen >= partLen) { md5Memcpy(buffer, inbuf, index, 0, partLen); md5Transform(buffer); for (i = partLen; i + 63 &lt; inputLen; i += 64) { md5Memcpy(block, inbuf, 0, i, 64); md5Transform(block); } index = 0; } else i = 0; // /* Buffer remaining input */ md5Memcpy(buffer, inbuf, index, i, inputLen - i); } /* * md5Final整理和填写输出结果 */ private void md5Final() { byte[] bits = new byte[8]; int index, padLen; // /* Save number of bits */ Encode(bits, count, 8); // /* Pad out to 56 mod 64. index = (int) (count[0] &gt;&gt;&gt; 3) & 0x3f; padLen = (index < 56) ? (56 - index) : (120 - index); md5Update(PADDING, padLen); // /* Append length (before padding) */ md5Update(bits, 8); // /* Store state in digest */ Encode(digest, state, 16); } /* * md5Memcpy是一个内部使用的byte数组的块拷贝函数,从input的inpos开始把len长度的 * 字节拷贝到output的outpos位置开始 */ private void md5Memcpy(byte[] output, byte[] input, int outpos, int inpos, int len) { int i; for (i = 0; i < len; i++) output[outpos + i] = input[inpos + i]; } /* * md5Transform是MD5核心变换程序,有md5Update调用,block是分块的原始字节 */ private void md5Transform(byte block[]) { long a = state[0], b = state[1], c = state[2], d = state[3]; long[] x = new long[16]; Decode(x, block, 64); /* Round 1 */ a = FF(a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */ d = FF(d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */ c = FF(c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */ b = FF(b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */ a = FF(a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */ d = FF(d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */ c = FF(c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */ b = FF(b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */ a = FF(a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */ d = FF(d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */ c = FF(c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */ b = FF(b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */ a = FF(a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */ d = FF(d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */ c = FF(c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */ b = FF(b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */ /* Round 2 */ a = GG(a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */ d = GG(d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */ c = GG(c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */ b = GG(b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */ a = GG(a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */ d = GG(d, a, b, c, x[10], S22, 0x2441453L); /* 22 */ c = GG(c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */ b = GG(b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */ a = GG(a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */ d = GG(d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */ c = GG(c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */ b = GG(b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */ a = GG(a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */ d = GG(d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */ c = GG(c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */ b = GG(b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */ /* Round 3 */ a = HH(a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */ d = HH(d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */ c = HH(c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */ b = HH(b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */ a = HH(a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */ d = HH(d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */ c = HH(c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */ b = HH(b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */ a = HH(a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */ d = HH(d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */ c = HH(c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */ b = HH(b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */ a = HH(a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */ d = HH(d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */ c = HH(c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */ b = HH(b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */ /* Round 4 */ a = II(a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */ d = II(d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */ c = II(c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */ b = II(b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */ a = II(a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */ d = II(d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */ c = II(c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */ b = II(b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */ a = II(a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */ d = II(d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */ c = II(c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */ b = II(b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */ a = II(a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */ d = II(d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */ c = II(c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */ b = II(b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; } /* * Encode把long数组按顺序拆成byte数组,因为java的long类型是64bit的, 只拆低32bit,以适应原始C实现的用途 */ private void Encode(byte[] output, long[] input, int len) { int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (byte) (input[i] & 0xffL); output[j + 1] = (byte) ((input[i] >>> 8) & 0xffL); output[j + 2] = (byte) ((input[i] >>> 16) & 0xffL); output[j + 3] = (byte) ((input[i] >>> 24) & 0xffL); } } /* * Decode把byte数组按顺序合成成long数组,因为java的long类型是64bit的, * 只合成低32bit,高32bit清零,以适应原始C实现的用途 */ private void Decode(long[] output, byte[] input, int len) { int i, j; for (i = 0, j = 0; j < len; i++, j += 4) output[i] = b2iu(input[j]) | (b2iu(input[j + 1]) << 8) | (b2iu(input[j + 2]) << 16) | (b2iu(input[j + 3]) << 24); return; } /* * b2iu是我写的一个把byte按照不考虑正负号的原则的"升位"程序,因为java没有unsigned运算 */ public static long b2iu(byte b) { return b < 0 ? b & 0x7F + 128 : b; } /* * byteHEX(),用来把一个byte类型的数转换成十六进制的ASCII表示, * 因为java中的byte的toString无法实现这一点,我们又没有C语言中的 sprintf(outbuf,"X",ib) */ public static String byteHEX(byte ib) { char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; char[] ob = new char[2]; ob[0] = Digit[(ib >>> 4) & 0X0F]; ob[1] = Digit[ib & 0X0F]; String s = new String(ob); return s; } }

2013-01-24

一张图片分割,用input框形成按钮

<img >/images/dl.gif" width="81" height="22" border="0" usemap="#Map"> 上面的图片在&lt;body&gt;中 而下面这句放入&lt;body&gt;外 <map name="Map"> <area shape="rect" coords="3,3,36,19" href="#"> <area shape="rect" coords="40,3,78,18" href="#"> </map>

2013-01-24

程序员面试之葵花宝典

1、面向对象的特征有哪些方面 2、String是最基本的数据类型吗?3、int 和 Integer 有什么区别 4、String 和StringBuffer的区别5、运行时异常与一般异常有何异同?6、说出Servlet的生命周期,并说出Servlet和CGI的区别。7、说出ArrayList,Vector, LinkedList的存储性能和特性8、EJB是基于哪些技术实现的?并说出SessionBean和EntityBean的区别,StatefulBean和StatelessBean的区别。9、Collection 和 Collections的区别。10、&和&&的区别。11、HashMap和Hashtable的区别。

2013-01-05

Hibernate中的query 分页.doc

Hibernate中的query 博客分类: • Hibernate HibernateSQLSQL ServerMySQLJDBC Hibernate中的query.setFirstResult(),query.setMaxResults(); 一、query.scroll()和query.setFirstResult(),query.setMaxResults();这两种方法都可以取到一定范围内的数据,用来数据分页显示。那么两者区别,以及两者的效率如何? 答:1.scroll是用JDBC2.0的可滚动结果集实现;query.setMaxResults();query.setFirstResult()是数据库SQL语句实现。 2.你说是在数据库就分页好呢?还是把结果集都取到内存再分页好呢?(应该是在数据库就分了好些吧,但是如果在内存分页的话,换页的时候是不是更快一些呢?) 3.在数据库进行分页是首选的方式。数据库分页实际上是利用数据库本身SQL扩展的功能进行分页,例如MySQL的 limit 0,50这样的SQL语句。不但速度快,而且非常节省内存。不过不是每种数据库的都有这种分页支持的SQL,例如SQL Server就不支持。 4.scroll是利用JDBC2.0的功能做分页的,那么就完全取决于特定数据库的JDBC Driver的实现了。事实上大部分JDBC Driver都是把所有的结果集都一次取到内存,然后再分页的。如果这个结果集非常大,例如几万条,不但程序执行速度会很慢,而且很容易导致out of memory。当然个别JDBC Driver使用了服务器端游标来实现,那么就不会导致这种问题,例如jTDS。 二、Hibernate可以使用Query.setMaxResults方法简单地设置需要查询的最大结果集。 然后Hibernate会自动根据所设置的数据库方言翻译成相应的SQL语句提交给数据库。比如如果数据库是Oracle,SQL Server等,则翻译为类似select ... top 10之类的SQL语句,若是MySQL,则翻译为select ... limit 10之类的SQL。 三、举例: Java代码 1. import org.hibernate.Query; 2. 3. query.setFirstResult(0),query.setMaxResults(4);相当于MySQL中的limit 0, 4; 4. public void testQuery() { 5. Session session = null; 6. try { 7. session = HibernateUtils.getSession(); 8. session.beginTransaction(); 9. Query query = session.createQuery("from User"); 10. query.setFirstResult(0);//从第一条记录开始 11. query.setMaxResults(4);//取出四条记录 12. List userList = query.list(); 13. for (Iterator iter=userList.iterator(); iter.hasNext();) { 14. User user = (User)iter.next(); 15. System.out.println(user.getId()); 16. System.out.println(user.getName()); 17. } 18. session.getTransaction().commit(); 19. }catch(Exception e) { 20. e.printStackTrace(); 21. session.getTransaction().rollback(); 22. }finally { 23. HibernateUtils.closeSession(session); 24. } 25. }

2012-12-27

表单验证大全

1. 长度限制 [removed] function test() { if(document.a.b.value.length>50) { alert&#40;"不能超过50个字符!"&#41;; document.a.b.focus(); return false; } } [removed] &lt;form name=a test()"&gt; &lt;textarea name="b" cols="40" wrap="VIRTUAL" rows="6"&gt;&lt;/textarea> &lt;input type="submit" name="Submit" value="check"&gt; &lt;/form&gt; 2. 只能是汉字 &lt;input 3." 只能是英文 [removed] function onlyEng() { if(!(event.keyCode&gt;=65&&event;.keyCode<=90)) event.returnvalue=false; } [removed] &lt;input 4. 只能是数字 [removed] function onlyNum() { if(!((event.keyCode&gt;=48&&event;.keyCode<=57)||(event.keyCode>=96&&event;.keyCode<=105))) //考虑小键盘上的数字键 event.returnvalue=false; } [removed] &lt;input 5. 只能是英文字符和数字 &lt;input " 6. 验证油箱格式 [removed] function isEmail(strEmail) { if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true; else alert&#40;"oh"&#41;; } [removed] &lt;input type=text 7. 屏蔽关键字(这里屏蔽***和****) [removed] function test() { if((a.b.value.indexOf ("***") == 0)||(a.b.value.indexOf ("****") == 0)){ alert&#40;":&#41;"); a.b.focus(); return false;} } [removed] &lt;form name=a test()"> &lt;input type=text name=b&gt; &lt;input type="submit" name="Submit" value="check"&gt; &lt;/form&gt; 8. 两次输入密码是否相同 &lt;FORM METHOD=POST ACTION=""&gt; &lt;input type="password" id="input1"&gt; &lt;input type="password" id="input2"&gt; &lt;input type="button" value="test" &lt;/FORM> [removed] function check() { with(document.all){ if(input1.value!=input2.value) { alert&#40;"false"&#41; input1.value = ""; input2.value = ""; } else document.forms[0].submit(); } } [removed] 够了吧 :) 屏蔽右键 很酷 oncontextmenu="return false" ondragstart="return false" onselectstart="return false" 加在body中 二 2.1 表单项不能为空 [removed] &lt;!-- function CheckForm() { if (document.form.name.value.length == 0) { alert&#40;"请输入您姓名!"&#41;; document.form.name.focus(); return false; } return true; } --&gt; [removed] 2.2 比较两个表单项的值是否相同 [removed] &lt;!-- function CheckForm() if (document.form.PWD.value != document.form.PWD_Again.value) { alert&#40;"您两次输入的密码不一样!请重新输入."&#41;; document.ADDUser.PWD.focus(); return false; } return true; } --&gt; [removed] 2.3 表单项只能为数字和"_",用于电话/银行帐号验证上,可扩展到域名注册等 [removed] &lt;!-- function isNumber(String) { var Letters = "1234567890-"; //可以自己增加可输入值 var i; var c; if(String.charAt( 0 )=='-') return false; if( String.charAt( String.length - 1 ) == '-' ) return false; for( i = 0; i < String.length; i ++ ) { c = String.charAt( i ); if (Letters.indexOf( c ) < 0) return false; } return true; } function CheckForm() { if(! isNumber(document.form.TEL.value)) { alert&#40;"您的电话号码不合法!"&#41;; document.form.TEL.focus(); return false; } return true; } --&gt; [removed] 2.4 表单项输入数值/长度限定 [removed] &lt;!-- function CheckForm() { if (document.form.count.value > 100 || document.form.count.value < 1) { alert&#40;"输入数值不能小于零大于100!"&#41;; document.form.count.focus(); return false; } if (document.form.MESSAGE.value.length<10) { alert&#40;"输入文字小于10!"&#41;; document.form.MESSAGE.focus(); return false; } return true; } //--&gt; [removed] 2.5 中文/英文/数字/邮件地址合法性判断 [removed] &lt;!-- function isEnglish(name) //英文值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charCodeAt(i) > 128) return false; } return true; } function isChinese(name) //中文值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charCodeAt(i) > 128) return true; } return false; } function isMail(name) // E-mail值检测 { if(! isEnglish(name)) return false; i = name.indexOf(" at "); j = name dot lastIndexOf(" at "); if(i == -1) return false; if(i != j) return false; if(i == name dot length) return false; return true; } function isNumber(name) //数值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charAt(i) < "0" || name.charAt(i) > "9") return false; } return true; } function CheckForm() { if(! isMail(form.Email.value)) { alert&#40;"您的电子邮件不合法!"&#41;; form.Email.focus(); return false; } if(! isEnglish(form.name.value)) { alert&#40;"英文名不合法!"&#41;; form.name.focus(); return false; } if(! isChinese(form.cnname.value)) { alert&#40;"中文名不合法!"&#41;; form.cnname.focus(); return false; } if(! isNumber(form.PublicZipCode.value)) { alert&#40;"邮政编码不合法!"&#41;; form.PublicZipCode.focus(); return false; } return true; } //--&gt; [removed] 2.6 限定表单项不能输入的字符 [removed] &lt;!-- function contain(str,charset)// 字符串包含测试函数 { var i; for(i=0;i<charset.length;i++) if(str.indexOf(charset.charAt(i))>=0) return true; return false; } function CheckForm() { if ((contain(document.form.NAME.value, "%\(\)><")) || (contain(document.form.MESSAGE.value, "%\(\)><"))) { alert&#40;"输入了非法字符"&#41;; document.form.NAME.focus(); return false; } return true; } //--&gt; [removed] 1. 检查一段字符串是否全由数字组成 --------------------------------------- [removed]&lt;!-- function checkNum(str){return str.match(/\D/)==null} alert&#40;checkNum("1232142141"&#41;) alert&#40;checkNum("123214214a1"&#41;) // --&gt;[removed] 2. 怎么判断是否是字符 --------------------------------------- if (/[^\x00-\xff]/g.test(s)) alert&#40;"含有汉字"&#41;; else alert&#40;"全是字符"&#41;; 3. 怎么判断是否含有汉字 --------------------------------------- if (escape(str).indexOf("%u")!=-1) alert&#40;"含有汉字"&#41;; else alert&#40;"全是字符"&#41;; 4. 邮箱格式验证 --------------------------------------- //函数名:chkemail //功能介绍:检查是否为Email Address //参数说明:要检查的字符串 //返回值:0:不是 1:是 function chkemail(a) { var i=a.length; var temp = a.indexOf('@'); var tempd = a.indexOf('.'); if (temp > 1) { if ((i-temp) > 3){ if ((i-tempd)>0){ return 1; } } } return 0; } 5. 数字格式验证 --------------------------------------- //函数名:fucCheckNUM //功能介绍:检查是否为数字 //参数说明:要检查的数字 //返回值:1为是数字,0为不是数字 function fucCheckNUM(NUM) { var i,j,strTemp; strTemp="0123456789"; if ( NUM.length== 0) return 0 for (i=0;i<NUM.length;i++) { j=strTemp.indexOf(NUM.charAt(i)); if (j==-1) { //说明有字符不是数字 return 0; } } //说明是数字 return 1; } 6. 电话号码格式验证 --------------------------------------- //函数名:fucCheckTEL //功能介绍:检查是否为电话号码 //参数说明:要检查的字符串 //返回值:1为是合法,0为不合法 function fucCheckTEL(TEL) { var i,j,strTemp; strTemp="0123456789-()# "; for (i=0;i<TEL.length;i++) { j=strTemp.indexOf(TEL.charAt(i)); if (j==-1) { //说明有字符不合法 return 0; } } //说明合法 return 1; } 7. 判断输入是否为中文的函数 --------------------------------------- function ischinese(s){ var ret=true; for(var i=0;i<s.length;i++) ret=ret && (s.charCodeAt(i)>=10000); return ret; } 8. 综合的判断用户输入的合法性的函数 --------------------------------------- [removed] //限制输入字符的位数开始 //m是用户输入,n是要限制的位数 function issmall(m,n) { if ((m<n) && (m>0)) { return(false); } else {return(true);} } 9. 判断密码是否输入一致 --------------------------------------- function issame(str1,str2) { if (str1==str2) {return(true);} else {return(false);} } 10. 判断用户名是否为数字字母下滑线 --------------------------------------- function notchinese(str){ var reg=/[^A-Za-z0-9_]/g if (reg.test(str)){ return (false); }else{ return(true); } } 11. form文本域的通用校验函数 --------------------------------------- 作用:检测所有必须非空的input文本,比如姓名,账号,邮件地址等等。 该校验现在只针对文本域,如果要针对form里面的其他域对象,可以改变判断条件。 使用方法:在要检测的文本域中加入title文字。文字是在提示信息,你要提示给用户的该字段的中文名。比如要检测用户名 html如下&lt;input name="txt_1" title="姓名"&gt;,当然,最好用可视化工具比如dreamweaver什么的来编辑域。 如果要检测数字类型数据的话,再把域的id统一为sz. javascript判断日期类型比较麻烦,所以就没有做日期类型校验的程序了.高手可以补充。 程序比较草,只是提供一个思路。抛砖引玉! :) 哦,对了,函数调用方法:&lt; form dovalidate()"&gt; function dovalidate() { fm=document.forms[0] //只检测一个form,如果是多个可以改变判断条件 for(i=0;i<fm.length;i++) { //检测判断条件,根据类型不同可以修改 if(fm[i].tagName.toUpperCase()=="INPUT" &&fm;[i].type.toUpperCase()=="TEXT" && (fm[i].title!="")) if(fm[i].value="/blog/="")// { str_warn1=fm[i].title+"不能为空!"; alert&#40;str_warn1&#41;; fm[i].focus(); return false; } if(fm[i].id.toUpperCase()=="SZ")//数字校验 { if(isNaN(fm[i].value)) { str_warn2=fm[i].title+"格式不对"; alert&#40;str_warn2&#41;; fm[i].focus(); return false; } } } return true; } 2 >表单提交验证类 2.1 表单项不能为空 [removed] &lt;!-- function CheckForm() { if (document.form.name.value.length == 0) { alert&#40;"请输入您姓名!"&#41;; document.form.name.focus(); return false; } return true; } --&gt; [removed] 2.2 比较两个表单项的值是否相同 [removed] &lt;!-- function CheckForm() if (document.form.PWD.value != document.form.PWD_Again.value) { alert&#40;"您两次输入的密码不一样!请重新输入."&#41;; document.ADDUser.PWD.focus(); return false; } return true; } --&gt; [removed] 2.3 表单项只能为数字和"_",用于电话/银行帐号验证上,可扩展到域名注册等 [removed] &lt;!-- function isNumber(String) { var Letters = "1234567890-"; //可以自己增加可输入值 var i; var c; if(String.charAt( 0 )=='-') return false; if( String.charAt( String.length - 1 ) == '-' ) return false; for( i = 0; i < String.length; i ++ ) { c = String.charAt( i ); if (Letters.indexOf( c ) < 0) return false; } return true; } function CheckForm() { if(! isNumber(document.form.TEL.value)) { alert&#40;"您的电话号码不合法!"&#41;; document.form.TEL.focus(); return false; } return true; } --&gt; [removed] 2.4 表单项输入数值/长度限定 [removed] &lt;!-- function CheckForm() { if (document.form.count.value > 100 || document.form.count.value < 1) { alert&#40;"输入数值不能小于零大于100!"&#41;; document.form.count.focus(); return false; } if (document.form.MESSAGE.value.length<10) { alert&#40;"输入文字小于10!"&#41;; document.form.MESSAGE.focus(); return false; } return true; } //--&gt; [removed] 2.5 中文/英文/数字/邮件地址合法性判断 [removed] &lt;!-- function isEnglish(name) //英文值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charCodeAt(i) > 128) return false; } return true; } function isChinese(name) //中文值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charCodeAt(i) > 128) return true; } return false; } function isMail(name) // E-mail值检测 { if(! isEnglish(name)) return false; i = name.indexOf(" at "); j = name dot lastIndexOf(" at "); if(i == -1) return false; if(i != j) return false; if(i == name dot length) return false; return true; } function isNumber(name) //数值检测 { if(name.length == 0) return false; for(i = 0; i < name.length; i++) { if(name.charAt(i) < "0" || name.charAt(i) > "9") return false; } return true; } function CheckForm() { if(! isMail(form.Email.value)) { alert&#40;"您的电子邮件不合法!"&#41;; form.Email.focus(); return false; } if(! isEnglish(form.name.value)) { alert&#40;"英文名不合法!"&#41;; form.name.focus(); return false; } if(! isChinese(form.cnname.value)) { alert&#40;"中文名不合法!"&#41;; form.cnname.focus(); return false; } if(! isNumber(form.PublicZipCode.value)) { alert&#40;"邮政编码不合法!"&#41;; form.PublicZipCode.focus(); return false; } return true; } //--&gt; [removed] 2.6 限定表单项不能输入的字符 [removed] &lt;!-- function contain(str,charset)// 字符串包含测试函数 { var i; for(i=0;i<charset.length;i++) if(str.indexOf(charset.charAt(i))>=0) return true; return false; } function CheckForm() { if ((contain(document.form.NAME.value, "%\(\)><")) || (contain(document.form.MESSAGE.value, "%\(\)><"))) { alert&#40;"输入了非法字符"&#41;; document.form.NAME.focus(); return false; } return true; } //--&gt; [removed]

2012-12-03

js编写的省市县级联

全国各省市级联菜单 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> &lt;html &lt;head> &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;无标题文档&lt;/title&gt; [removed][removed] [removed][removed] &lt;/head&gt; &lt;body&gt; <select id="SelectPro" <select id="SelectCity" <select id="SelectArea" ></select> &lt;input name="" type="button" value="显示选中数据" &lt;/body> &lt;/html&gt;

2012-12-03

java通过js上传文件

简单的利用java与js实现文件上传 package com.fendou.myString; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; public class FileUpload extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean a=ServletFileUpload.isMultipartContent(request); if(a){ FileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload=new ServletFileUpload (factory); Iterator items; try{ items=upload.parseRequest (request).iterator(); while(items.hasNext()){ FileItem item=(FileItem) items.next(); if(!item.isFormField()){ String name=item.getName (); String fileName=name.substring(name.lastIndexOf("\\")+1, name.length()); String path=request.getRealPath("file")+File.pathSeparatorChar+fileName; File uploadFile=new File &#40;path&#41;; request.getSession ().setAttribute("file", uploadFile); item.write(uploadFile); response.setContentType ("text/html"); response.setCharacterEncoding("utf-8"); PrintWriter out=response.getWriter(); // out.print("<font size='2'> 上传的文件为:"+name+"<br>"); // out.print("保存在服务器上 的地址为:"+path+"</font>"); } } }catch(Exception e){ e.printStackTrace(); } } response.sendRedirect("smartupload.jsp"); } }

2012-10-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除