俊星的BLOG

#

Angela's Ashes 天使的孩子

今天偶然在一片博客上看到了《Angela's Ashes》的介绍,又在YOUKU上发现了一段原声音乐,带点忧伤,很合我胃口。
不过,在网上没有找到能免费看的,那就上淘宝买一张吧。

posted @ 2009-05-29 16:43 俊星 阅读(95) | 评论 (0)编辑 收藏

MYSQL Access denied 问题的解决

今天尝试通过JDBC连接局域网的另一台机器,抛出了如下异常:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'wiki'
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
2985)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:
885)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:
3421)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:
1247)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:
2775)
    at com.mysql.jdbc.Connection.<init>(Connection.java:
1555)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:
285)
    at java.sql.DriverManager.getConnection(DriverManager.java:
525)
    at java.sql.DriverManager.getConnection(DriverManager.java:
171)
    at test.tool.WikiStat.getConn(WikiStat.java:
18)
    at test.tool.WikiStat.main(WikiStat.java:
23)

具体的解决方法为,授予相关用权限,如:
mysql> grant select on *.* to 'root'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges
;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

命令“grant select on *.* to 'root'@'%' identified by 'password'”所作的事情其实就是在“mysql.user”表中添加了一行记录,
因此如果需要删除某个授权,直接找到user表执行删除就OK了。

posted @ 2009-05-27 19:54 俊星 阅读(2330) | 评论 (0)编辑 收藏

JAVA小工具之文件查找

需要在一堆文件夹中查找一个exe文件,实在无法忍受windows的查找功能,自己写了一个简单的JAVA类,实现了查找:
package test.tool;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 
 * 
@author kinkding
 * @history 2009-5-26
 
*/

public class FindFile {
    
private String fileName = "";
    
private String dir = "";
    
private Matcher m = null;
    
private int count = 0;

    
public FindFile() throws IOException {
        String f 
= FindFile.class.getResource("findfile.properties").getFile();
        BufferedReader read 
= new BufferedReader(new FileReader(f));
        dir 
= read.readLine().trim();
        fileName 
= read.readLine().trim();
        Pattern p 
= Pattern.compile(fileName);
        m 
= p.matcher("");
    }


    
public void find() {
        File root 
= new File(dir);
        
for (File f : root.listFiles()) {
            
if (f.isDirectory()) {
                dir 
= f.getAbsolutePath();
                find();
            }
 else {
                m.reset(f.getName());
                
if (m.find()) {
                    count
++;
                    System.out.println(f.getAbsolutePath());
                }

            }

        }

    }


    
public static void main(String[] args) {
        
try {
            FindFile ff 
= new FindFile();
            ff.find();
            System.out.println(
"\n共找到文件数目:" + ff.count);
        }
 catch (IOException e) {
            e.printStackTrace();
        }

    }

}


findfile.properties:
F:\download
vod.
*.exe

运行效果如下:
F:\download\firefox\vodplayer.exe
F:\download\ie\vodplayer.exe

共找到文件数目:
2

相关说明:
之所以加载配置文件时不采用java.util.Properties类,是因为配置的路径“F:\download”通过getProperty方法取得时候,去掉了文件分割符,所以直接就采用流的方式读取,第一行默认目录,第二行默认文件名,并且对文件名采用正则匹配。

posted @ 2009-05-26 22:54 俊星 阅读(836) | 评论 (0)编辑 收藏

IE修复的相关命令

IE修复的相关命令:
"%ProgramFiles%\Internet Explorer\iexplore.exe" /rereg

regsvr32 Shdocvw.dll
regsvr32 Oleaut32.dll
regsvr32 Actxprxy.dll
regsvr32 Mshtml.dll
regsvr32 Urlmon.dll
regsvr32 browseui.dll

regsvr32 hhctrl.ocx

posted @ 2009-05-26 20:22 俊星 阅读(99) | 评论 (0)编辑 收藏

JAVA字符编码

测试代码:
    public static void main(String[] args) {
        Locale.setDefault(Locale.US);
        String str 
= "中G中";
        String codes[] 
= "iso8859-1""utf-8""utf-16""unicode""gbk""gb2312" };
        
try {
            System.out.println(str);
            System.out.println(
"default code:" + System.getProperty("file.encoding"));
            
for (String s : codes) {
                System.out.println(s 
+ "" + toHex(str.getBytes(s)));
            }

        }
 catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }


    
private static String toHex(byte[] buffer) {
        StringBuffer sb 
= new StringBuffer(buffer.length * 3);

        
for (int i = 0; i < buffer.length; i++{
            sb.append(Character.forDigit((buffer[i] 
& 0xf0>> 416));
            sb.append(Character.forDigit(buffer[i] 
& 0x0f16));
            sb.append(
" ");
        }


        
return sb.toString();
    }

输出如下:
中G中
default code:GBK
iso8859-
1: 3f 47 3f 
utf-
8: e4 b8 ad 47 e4 b8 ad 
utf-
16: fe ff 4e 2d 00 47 4e 2d 
unicode: ff fe 2d 4e 
47 00 2d 4e 
gbk: d6 d0 
47 d6 d0 
gb2312: d6 d0 
47 d6 d0 

相关说明:
1、通过System.getProperty("file.encoding")获取到当前JVM的默认字符编码方式,如GBK
2、iso8859-1则是应用于英文和欧洲其他语言的单字节编码字符集,“3f”其实对应就是“?”。
3、utf-8则是unicode编码的一种转换方式(Unicode Transformation Format),兼容于ASCII编码,如对于中文则使用3个字节来存储,对于英文使用一个字节存储。
4、utf-16是unicode编码的另一种转换方式,每个直接都采用2个字节来存储,所以不兼容于ASCII;
      其中“fe ff”是Byte Order Mark(BOM)表示采用的编码方式为utf-16。
5、此处的unicode输出和utf-16本质相同,只不过大小尾序的问题导致单个字节输出顺序相反;
      其中对于windows和linux平台的utf-16默认采用小尾序(LE little Endion),mac平台采用大尾。
6、gbk和gb2312是中文字符集,对于每个字符均采用2个字节存储,其中gbk兼容gb2312并且还可表示繁体。

关于存储字节的计算,假设现在有N个中文和M个英文字符,则如下的计算方式(编码方式:字节数):
GBK:2*N+M
UTF-8:3*N+M
UTF-16:2*(N+M+1)
ISO8859-1:N+M

posted @ 2009-05-26 00:12 俊星 阅读(212) | 评论 (0)编辑 收藏

仅列出标题
共10页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last