Java获取随机字符串
2007-03-30 10:01 | Filed Under Java |
- import java.util.Random;
- public static String getRandomString(int length) {
- StringBuffer buffer = new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
- StringBuffer sb = new StringBuffer();
- Random r = new Random();
- int range = buffer.length();
- for (int i = 0; i < length; i ++) {
- sb.append(buffer.charAt(r.nextInt(range)));
- }
- return sb.toString();
- }
这个没啥意思,就是随机数用的不多,每次要用都记不住,在这里备个份@@
标签:Java, random, 随机相关日志
PreparedStatement的怪异问题
2007-03-29 22:46 | Filed Under Java |
详细代码和数据库(Oracle)见附件,本来很简单的事情没想到让我碰到了诡异的问题。
pstmt.setString(1, customItems);
pstmt.setString(2, "4788");
这么写必然报java.sql.SQLException: ORA-01461: 仅可以为插入 LONG 列的 LONG 值赋值。
如果把第二个参数值直接写入sql里就没问题,可以肯定的是原因必然是因为customItems超过一定长度,据smth上大大说当长度超过4000/3的时候可能会出问题。
现在为了解决无法插入的问题,只能先把除了customitems字段的insert进去,然后再来update它,晕。
PreparedStatement有什么特殊限制吗?
下载:测试代码及数据库
标签:Java, jdbc, PreparedStatement, sql相关日志
咱也开始卖光盘了
2007-03-28 19:08 | Filed Under Life |
经过两小时的手工作坊式包装,也像模像样了。
看看图,虽然比较简陋,不过也是我们单位第一个作为软件产品出售的,新注册公司的第一单业务吧~
FTPClient中retrieveFileStream的用法
2007-03-27 11:45 | Filed Under Java |
工作需要使用了org.apache.commons.net.ftp.FTPClient来操作FTP,记录一下心得。
这个类封装的很完善,使用起来也很简单,只是在使用retrieveFileStream的时候碰到了一点小问题,就是不知道怎么完成传输状态,尝试发送abor指令也不行。在咨询了bianbian和查看了源代码之后看到这一段说明以后解决问题:
* You must close the InputStream when you
* finish reading from it. The InputStream itself will take care of
* closing the parent data connection socket upon being closed. To
* finalize the file transfer you must call
* {@link #completePendingCommand completePendingCommand } and
* check its return value to verify success.
代码如下:
- import org.apache.commons.net.ftp.FTPClient;
- public class TestFTP {
- public static void main(String[] args) {
- try {
- FTPClient ftp = new FTPClient();
- // initialize ftp connection
- /*
- *
- */
- String remotefile = "test.xml";
- InputStream is = null;
- is = ftp.retrieveFileStream(remotefile);
- if (is != null) {
- is.close();
- }
- if (!ftp.completePendingCommand()) {
- ftp.logout();
- ftp.disconnect();
- }
- // continue
- } catch (SocketException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Windows Server 2003 Service Pack 2(32-bit x86) 中文版
2007-03-27 09:23 | Filed Under Software |
下载:轻点
升级完没啥感觉,就是uxtheme.dll需要重新破解
补充:类似于升级SP1时候的问题,升级完后IE在解析脚本时出现很多问题,建议直接安装集成版而不是通过升级方式安装
标签:sp, uxtheme, windows相关日志


