ice world

There is nothing too difficult if you put your heart into it.
posts - 104, comments - 103, trackbacks - 0, articles - 0

2013年11月21日

这个问题很多小伙伴都遇到了,网上搜罗了半天也没找到太好、太完美的解决办法,有人说是因为安装IE11时联网了,导致自动打了补丁,这个补丁可以自动检查IE主页是否损坏,可以通过卸载相应的补丁解决,我同时又找到了另外一个通过修改hosts文件的方法,貌似目前解决了我的问题,修改方法如下: 使用记事本打开 C:\Windows\System32\drivers\etc\hosts 文件,在最下面追加一行: 127.0.0.1 ieonline.microsoft.com

posted @ 2016-08-12 10:47 IceWee 阅读(867) | 评论 (0)编辑 收藏

将JDK中BIN文件夹下的 msvcr71.dll 这个文件复制到 TOMCAT 中的 BIN 下

posted @ 2016-01-18 13:43 IceWee 阅读(416) | 评论 (0)编辑 收藏

有段日子没做记录了,这段日子一直在排雷(前人埋下的隐患代码,或者直接说bug),今天这个雷让我排了将近大半天,因为是正式上线的系统,只能看后台日志,不能调试,打印出的异常信息不完整,种种的条件不充分,导致问题很难定位。标题上的两个异常,第一个一看就明白是插入的数值大于数据库字段长度,第二个多是因为Number类型的字段导致,比如精度不足。

我们的这次问题原因是程序员在做除法运算时没有对除数进行非零判断,导致计算出来的数值非法,插入数据库失败,请看代码:
public static void main(String[] args) {
        
double a = 10;
        
double b = 0;
        
double c = 0;
        
        
double m = a/c;
        
double n = b/c;
        
        System.out.println(m);
        System.out.println(n);
    }

经过计算后,m和n的值分别是多少?没在实际开发中遇到的可能不知道,或者你有个好习惯不会出现这样的bug,请看结果:
Infinity
NaN

被除数非零,除数为零做除法的结果是字符串“Infinity”,翻译成中文就是“无限”,你的中学数学老师可能说过;
被除数为零,除数为零做触发的结果是字符串“NaN”,即不是有效的数字。

就是这个“Infinity”花费了我一小天的时间才定位。下面详述问题定位的方法。

异常1:ORA-01438: value larger than specified precision allowed for this column
了解点数据库的打眼一看就知道插入的数值超过了表字段长度,但你知道是哪个表哪个字段吗?我不知道,于是网上查阅了下,Oracle数据库服务器在Linux上。

命令行登陆到数据库所在服务器,进入Oracle的安装目录,假设是/opt/oracle/
进入到如下目录:/opt/oracle/admin/实例名/udump
中间的数据库实例名根据实际情况修改,udump目录下会有一堆的.trc文件,这些文件记录了所有操作当前数据库出现异常的堆栈信息。为了定位问题,我将该目录下的所有.trc文件都删除了(当然,删除之前把udump目录整个备份了),再进行一次系统的业务操作,查看一下udump目录,发现立刻生成一个新 的.trc文件,打开查看(内容片段):
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning
, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
ORACLE_HOME 
= /u01/app/oracle/product/10.2/db_1
System name:    AIX
Node name
:    gsdj1
Release
:    1
Version
:    6
Machine
:    00CFD4644C00
Instance name
: bjwd1
Redo thread mounted by this instance: 1
Oracle process number
: 132
Unix process pid
: 48300280, image: oracle@gsdj1

*** SERVICE NAME:(bjwd) 2014-03-28 16:48:05.683
*** SESSION ID:(2969.439612014-03-28 16:48:05.683
*** 2014-03-28 16:48:05.683
ksedmp
: internal or fatal error
ORA
-01438: value larger than specified precision allowed for this column
Current SQL statement 
for this session:
insert into CP_TEMP_STOCKTRAN (APPLY_ID, ALIEN, CER_TYPE, CER_NO, TRANS_AM, TRANS_AM_PR, TRANS_TYPE, TRANS_DATE, ENDORSOR, BLIC_TYPE, ALIEN_ID, ENDORSOR_ID, STOCKTRAN_ID) values (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13)

黄色背景红色字体的SQL就是罪魁祸首,这仅仅能定位发生问题的数据库表,字段还得自己排查。异常1让我定位到了这里,这时想起了异常2。


异常2: Could not synchronize database state with session
之前也搜索过这个异常,多数是由于Number类型的字段导致。冷静的思考一下,平常我们在做表设计时,会把文字类型的字段设置大一些,Number类型的精度也会根据实际业务进行设计,但往往Number类型的字段最容易出问题:
1、如果将非Number值插入该字段,比如字符串
2、如果插入的数值精度过多,如字段设计Number(10,2),也就是最大支持8为整数和两位小数,要插入34.121313就会失败

根据表名定位到hibernate的映射文件以及实体类,再从业务功能入口(一个action方法)搜索,终于定位到一个业务接口做了该实体类的保存代码,定位到了那个字段,定位到了做除法没有判断除数是否为0。








posted @ 2014-03-28 18:54 IceWee 阅读(830) | 评论 (0)编辑 收藏

网络配置:
临时(重丢失)
ifconfig eth0 192.168.1.xxx netmask 255.255.xxx.0


永久(重启有效)
vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.xxx
        netmask 255.255.xxx.0
        network 192.168.1.1
        broadcast 192.168.1.255
        gateway 192.168.1.1
        
# dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 202.106.196.115


由于非法关机导致重启后无法联网

ifconfig eth0 192.168.1.xxx netmask 255.255.xxx.0 

route add default gw 192.168.1.1

重启后配置丢失,所以必须在重启之前执行:
apt-get update

apt-get install ifupdown

不能联网是因为非法关机导致ifup脚本丢失





posted @ 2014-01-24 10:50 IceWee 阅读(869) | 评论 (0)编辑 收藏

源机器:192.168.1.1
备份机器:192.168.1.2

前提条件:
1、两台机器的网络是连通的
2、两台机器必须同时安装了SVN服务器

假设:
源机器上需要同步的库名为autoSync,访问地址为:svn://192.168.1.1/autoSync,对其具备读写权限的账户:sync/sync

备份机器配置:
1、创建与源机器库名相同的空库
# 假设备份机器的SVN根目录建立在 /home/backup/svn/repository下
svnadmin create /home/backup/svn/repository/autoSync

2、配置备份机器上的autoSync
分别修改conf下的svnserve.conf、passwd、authz,根据实际情况配置,假设创建了用户sync/sync,对库autoSync具备读写权限,配置方法略,配置完成后启动SVN服务

3、创建并修改pre-revprop-change文件
cd /home/backup/svn/repository/autoSync/hooks
cp pre
-revprop-change.tmpl pre-revprop-change
vi pre-revprop-change

将文件末尾的“exit 1”改为“exit 0”即可,保存退出
REPOS="$1"
REV
="$2"
USER
="$3"
PROPNAME
="$4"
ACTION
="$5"

if
[ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi

echo
"Changing revision properties other than svn:log is prohibited" >&2
exit
0

增加可执行权限
chmod 755 pre-revprop-change

4、初始化
命令:
svnsync init --username 用户名 --password 密码 备份机器库URL 源机器库URL

说明:
用户名和密码是对源机器SVN库具备读写权限的SVN用户

示例:
svnsync init --username sync --password sync svn://192.168.1.2/autoSync svn://192.168.1.1/autoSync

5、首次同步
首次同步即为一次全备份过程,在此期间请停止客户端段源机器哦一切操作(提交代码等)
命令:
svnsync sync 备份机器库URL
示例:
svnsync sync svn://192.168.1.2/autoSync

源机器配置
6、增量自动同步配置
创建并修改post-commit文件
# 假设源机器的SVN根目录建立在 /home/svn/repository下
cd /home/svn/repository/autoSync/hooks
cp post
-commit.tmpl post-commit
vi post
-commit

在文件末尾追加:svnsync sync --non-interactive 备份机器库URL --username 用户名 --password 密码

说明:
用户名和密码是对备份机器SVN库具备读写权限的SVN用户

示例:
svnsync sync --non-interactive svn://192.168.1.2/autoSync --username sync --password sync

7、术语
配置完成,今后客户端再向SVN(192.168.1.1)提交文件时,会自动触发源机器(192.168.1.1)向备份机器(192.168.1.2)提交更新

8、版本库UUID一致性
首先查看源机器库的UUID,假设得到的是:fcdcbee9-6be3-4575-8d4a-681ec15ad8e0
svnlook uuid svn://192.168.1.1/autoSync

更新备份机器库的UUID为源机器库的UUID
svnadmin setuuid svn://192.168.1.2/autoSync fcdcbee9-6be3-4575-8d4a-681ec15ad8e0




posted @ 2014-01-23 11:08 IceWee 阅读(615) | 评论 (0)编辑 收藏

本文记录的安装步骤是基于基本安装后的Debian,启动后漆黑一片,只有命令行,采用在线安装方式,因此配置中国的镜像软件源能提高软件的下载速度,首先配置软件源。

备份源文件
# cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑源文件
# nano /etc/apt/sources.list

注释掉本地光盘源这一行,注释后如:
# deb cdrom:[Debian GNU/Linux 6.0.7 _Squeeze_ - Official amd64 NETINST Binary-1 20130223-18:50]/ squeeze main

取消下面两行官方源前面的注释
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main

追加163的镜像源地址
deb http://mirrors.163.com/debian/ squeeze main non-free contrib
deb http://mirrors.163.com/debian/ squeeze-proposed-updates main contrib non-free
deb http://mirrors.163.com/debian-security/ squeeze/updates main contrib non-free
deb-src http://mirrors.163.com/debian/ squeeze main non-free contrib
deb-src http://mirrors.163.com/debian/ squeeze-proposed-updates main contrib non-free
deb-src http://mirrors.163.com/debian-security/ squeeze/updates main contrib non-free
deb http://ftp.sjtu.edu.cn/debian/ squeeze main non-free contrib
deb http://ftp.sjtu.edu.cn/debian/ squeeze-proposed-updates main contrib non-free
deb http://ftp.sjtu.edu.cn/debian-security/ squeeze/updates main contrib non-free
deb-src http://ftp.sjtu.edu.cn/debian/ squeeze main non-free contrib
deb-src http://ftp.sjtu.edu.cn/debian/ squeeze-proposed-updates main contrib non-free
deb-src http://ftp.sjtu.edu.cn/debian-security/ squeeze/updates main contrib non-free

保存修改
# ctrl + o 回车
退出
# ctrl + x

更新源
# apt-get update

更新系统
# apt-get upgrade

安装SVN服务器
# apt-get install subversion subversion-tools

安装完成后可以运行命令查看SVN服务器版本信息
# svnserve --version

配置SVN
首先创建版本库的根目录,如位置:/home/svn/repository,所有项目都将在该目录下创建相应子文件夹
# mkdir –p /home/svn/repository

创建项目版本库test(仅为演示)
# svnadmin create /home/svn/repository/test


修改SVN配置文件
nano /home/svn/repository/test/conf/svnserve.conf

以下为文件内容:
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults
# 未授权配置为禁止访问none,已授权配置为可以读写write
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
# 用户数据库文件,配置授权用户,当前使用的文件是和svnserve.conf在相同目录下的passwd文件,也可以指定其他绝对路径文件,如:/home/svn/passwd
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
# 授权文件,配置如同用户配置
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
# realm = My First Repository

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256


保存
# ctrl + o 回车

退出
# ctrl + x

配置用户
# nano passwd

以下为文件内容:
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
IceWee = IceWee

增加用户IceWee,密码也为IceWee,=号两侧需要有空格,保存(ctrl + o 回车)退出(ctrl + x)

配置访问权限
# nano authz

以下为文件内容:
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
developers = IceWee

# [/foo/bar]
# harry = rw
# &joe = r
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

[/]
* = r
IceWee = rw
@developers = rw

[/tags]
IceWee = rw

默认所有用户可读取根,IceWee可以读写根。可以分别对子目录进行授权,如上的tags目录,IceWee具有读写权限,以及IceWee所在的组developers也具备读写权限。

启动SVN服务器
# svnserve -d -r /home/svn/repository
-d含义为后台运行(daemon),-r指定的根目录,如访问test应该使用这样的地址 svn://hostname:port/test

停止SVN服务
# killall svnserve

备份还原命令,与oracle的备份有些类似
导出
# svnadmin dump /home/svn/repository/test > /home/bak/test.dump

导入
# svnadmin load /home/svn/repository/demo < /home/bak/demo.dump
导入前提:
必须先创建要导入版本库目录,如上的demo,则需要做以下操作
# svnadmin create /home/svn/respository/demo
修改svnserve.conf、passwd、authz等文件,前面已介绍


 





posted @ 2014-01-17 15:48 IceWee 阅读(1190) | 评论 (0)编辑 收藏


2013年12月10日
---------------------------
冒泡排序
void bubble(int[] array) {
       
boolean swaped = true;
       
for (int t = 1; t < array.length && swaped; t++) {
            swaped
= false;
           
for (int i = 0; i < array.length - t; i++) {
               
if (array[i] > array[i + 1]) {
                  
int temp = array[i];
                    array[i]
= array[i + 1];
                    array[i
+ 1] = temp;
                    swaped
= true;
                }

            }

        }

    }


2013年11月26日
---------------------------
1、String的split方法
平常总是这样用,String str = "a,b,c,d,e"; String[] arr = str.split(",");
其实还可以这样用,String lan = "Java;C#?C++:C"; String si = lan.split("[;?:]"); 返回的是字符串数组{"Java", "C#", "C++", "C"}


2013年11月21日
---------------------------

1、Java对象池知多少?
示例:String s1 = "abc"; String s2 = "abc"; s1 == s2 返回ture还是false?只要不是new出来的都先从对象池中读取,因此结果为true,两个变量指向的是同一块内存空间地址。

Java除了String类使用了对象池以外,还有5个基本类型的封装类:Byte、Short、Integer、Long和Character,例如:Integer inA = 20; Integer inB = 20; 那么 inA == inB 的结果为true,其他类与此相同,不做示例。

特别注意:
(1)浮点型的两个封装类Float和Double并没有参与对象池;
(2)整形封装类(Byte、Short、Integer和Long)只有数值小于或等于127时才使用对象池,例如:Integer x = 128; Integer y = 128; x == y的结果为false。

2、Java变量命名规范
A. String #name = "Joe";
B. int $age = 30;
C. Double _height = 174.4;
D. float ~temp = 37.6;
以上A到D,哪个无法通过编译?答案是A和D,因为Java变量名只允许字母、下划线(_)、美元符($)开头,那么 int _ = 30; String $$ = "I DO";可以吗?答案是完全可以,但很少有人这样定义变量名,虽然没有违法命名规范,但最后我估计程序员自己都会被自己绕晕。

3、0和1能标识布尔值吗?
int flag = 0;
if (flag) {
    System.out.print("error");
}
error会打印吗?不会,因为根本就不会编译通过,编译器会提示flag是int类型而不是boolean类型,如果你会有这种想法可能之前学过C,C总的0和1可以标识布尔的。

4、静态导入
例:
ClassA.java
package bing.test.sub1;

public class ClassA {
  
public static final int MAX_INT = Integer.MAX_VALUE;
}



ClassB.java
package bing.test.sub2;

import static bing.test.sub1.ClassA.MAX_INT;

public class ClassB {
 
public static void main(String[] args) {
System.out.println(MAX_INT);
  }

}

输出:2147483647。不仅仅可以静态导入其他类的静态属性还可以导入静态方法,这些特性在实际开发中很少见。









posted @ 2013-11-21 12:49 IceWee 阅读(448) | 评论 (0)编辑 收藏