Mar 19
出现这个问题是因为我使用的是Tomcat+JDBC驱动连接MSSQL数据库导致的.  
  其实并不是本身JDBC驱动不好.问题是MS的JDBC驱动(也就是3个JAR包)不支持二次查询导致的.  
  而用过Hibernate的人都知道,在用*.hbm.xml文件中通常用Set的时候需要采用延时的检索机制来减少不必要的开销.当如果我们需要采取立即检索的时候,通常是在代码中调用Hibernate.initialize()方法,而不是将lasy改为false,理由是这样程序员可以根据业务需要来控制检索策略.  
  当我们之前调用itemDAO.findById(item.getItemId());的时候,Hibernate会到DB中去检索一次数据,由于set的lasy属性为true,因此只是单纯的执行:  
  select   *   from   table   where   ID=?  
  而当执行Hibernate.initialize(item2.getStoreItems());则Hibernate会根据上次查询的结果再次去DB中检索数据,但是...JDBC不支持二次查询,因此最后就直接反馈给我们  
  could not initialize a collection

  最后解决问题的办法:更换驱动  
  用JTDS驱动,也就是采用jtds-1.2.jar而不用msbase.jar、mssqlserver.jar、msutil.jar这三个JAR包。将jtds-1.2.jar放到我们的lib目录的构件路径下。再次测试,成功通过。
Mar 16

ajax类库 不指定

Wudi , 20:50 , 软件编程 , 评论(1) , 引用(0) , 阅读(943) , Via 本站原创
/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ?2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
  this.xmlhttp = null;

  this.resetData = function() {
    this.method = "POST";
      this.queryStringSeparator = "?";
    this.argumentSeparator = "&";
    this.URLString = "";
    this.encodeURIString = true;
      this.execute = false;
      this.element = null;
    this.elementObj = null;
    this.requestFile = file;
    this.vars = new Object();
    this.responseStatus = new Array(2);
    };

  this.resetFunctions = function() {
      this.onLoading = function() { };
      this.onLoaded = function() { };
      this.onInteractive = function() { };
      this.onCompletion = function() { };
      this.onError = function() { };
    this.onFail = function() { };
  };

  this.reset = function() {
    this.resetFunctions();
    this.resetData();
  };

  this.createAJAX = function() {
    try {
      this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {
      try {
        this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
        this.xmlhttp = null;
      }
    }

    if (! this.xmlhttp) {
      if (typeof XMLHttpRequest != "undefined") {
        this.xmlhttp = new XMLHttpRequest();
      } else {
        this.failed = true;
      }
    }
  };

  this.setVar = function(name, value){
    this.vars[name] = Array(value, false);
  };

  this.encVar = function(name, value, returnvars) {
    if (true == returnvars) {
      return Array(encodeURIComponent(name), encodeURIComponent(value));
    } else {
      this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
    }
  }

  this.processURLString = function(string, encode) {
    encoded = encodeURIComponent(this.argumentSeparator);
    regexp = new RegExp(this.argumentSeparator + "|" + encoded);
    varArray = string.split(regexp);
    for (i = 0; i < varArray.length; i++){
      urlVars = varArray[i].split("=");
      if (true == encode){
        this.encVar(urlVars[0], urlVars[1]);
      } else {
        this.setVar(urlVars[0], urlVars[1]);
      }
    }
  }

  this.createURLString = function(urlstring) {
    if (this.encodeURIString && this.URLString.length) {
      this.processURLString(this.URLString, true);
    }

    if (urlstring) {
      if (this.URLString.length) {
        this.URLString += this.argumentSeparator + urlstring;
      } else {
        this.URLString = urlstring;
      }
    }

    // prevents caching of URLString
    this.setVar("rndval", new Date().getTime());

    urlstringtemp = new Array();
    for (key in this.vars) {
      if (false == this.vars[key][1] && true == this.encodeURIString) {
        encoded = this.encVar(key, this.vars[key][0], true);
        delete this.vars[key];
        this.vars[encoded[0]] = Array(encoded[1], true);
        key = encoded[0];
      }

      urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
    }
    if (urlstring){
      this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
    } else {
      this.URLString += urlstringtemp.join(this.argumentSeparator);
    }
  }

  this.runResponse = function() {
    eval(this.response);
  }

  this.runAJAX = function(urlstring) {
    if (this.failed) {
      this.onFail();
    } else {
      this.createURLString(urlstring);
      if (this.element) {
        this.elementObj = document.getElementById(this.element);
      }
      if (this.xmlhttp) {
        var self = this;
        if (this.method == "GET") {
          totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
          this.xmlhttp.open(this.method, totalurlstring, true);
        }else if(this.method == "FILE") {
          this.xmlhttp.open(this.method, this.requestFile, true);
          try {
            this.xmlhttp.setRequestHeader("Content-Type", "multipart/form-data")
          } catch (e) { }
        } else {
          this.xmlhttp.open(this.method, this.requestFile, true);
          try {
            this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
          } catch (e) { }
        }

        this.xmlhttp.onreadystatechange = function() {
          switch (self.xmlhttp.readyState) {
            case 1:
              self.onLoading();
              break;
            case 2:
              self.onLoaded();
              break;
            case 3:
              self.onInteractive();
              break;
            case 4:
              self.response = self.xmlhttp.responseText;
              self.responseXML = self.xmlhttp.responseXML;
              self.responseStatus[0] = self.xmlhttp.status;
              self.responseStatus[1] = self.xmlhttp.statusText;

              if (self.execute) {
                self.runResponse();
              }

              if (self.elementObj) {
                elemNodeName = self.elementObj.nodeName;
                elemNodeName.toLowerCase();
                if (elemNodeName == "input"
                || elemNodeName == "select"
                || elemNodeName == "option"
                || elemNodeName == "textarea") {
                  self.elementObj.value = self.response;
                } else {
                  self.elementObj.innerHTML = self.response;
                }
              }
              if (self.responseStatus[0] == "200") {
                self.onCompletion();
              } else {
                self.onError();
              }

              self.URLString = "";
              break;
          }
        };

        this.xmlhttp.send(this.URLString);
      }
    }
  };

  this.reset();
  this.createAJAX();
}
Mar 14
最近整理项目框架,配置映射的时候经常出错,因为是改的旧程序,所以总结一下出错的几个地方:
Web.xml struts配置文件路径错误 servlet路径错误
struts-config.xml 与action对应错误
hibernate.cfg.xml 主要是把所有的映射的mapping的错误
XXXXXXXXX.hbm.xml 与表的对应,与字段的对应,与pojo里的对应
最后还有读取hibernate配置文件路径的问题。

这几天大概碰到的这些问题,ms有点多,但都值得注意。
Mar 13
今天搞页面效果,怎么都没办法把tree搞成透明的,终于给找到了个方法,与大家一起分享。
打开treeview.htc  
  修改  
  function   buildTreeFromRoot()  
  {  
          //treeviewNode   =   element.document.createElement("HTML");  
          //var   bodyNode   =   element.document.createElement("BODY");  
    
   //startmodify
  treeviewNode   =   element.document.createElement("DIV");  
  bodyNode   =   element.document.createElement("SPAN");  
  //end   modify  

  }  
Mar 12

php小偷示例 不指定

Wudi , 21:07 , 软件编程 , 评论(0) , 引用(0) , 阅读(690) , Via 本站原创
为了顺利的完成QQ代码程序,先研究一下别人的一个小偷程序。
1、对原网站进行代码分析
首先确定视听mtv的地址是: http://mtv.8391.com/player.asp?id=ID
查看其原文件,判断出调用mtv路径的文件: http://mtv.8391.com/Yxwen.asp?id=ID
利用代码查看程序,取得 http://mtv.8391.com/Yxwen.asp?id=3488页面代码(3488为随机,只是了解页面代码)
2、对要偷取的页面进行代码分析
http://mtv.8391.com/Yxwen.asp?id=3488页面代码如下:
CODE: ??? 运行代码 - 复制代码 - 保存代码 ???

< entry SKIPIFREF="YES">
< title>I Believe In Love
< author> 蓝牙音乐网 - www.8391.com
< copyright> 蓝牙音乐网 - www.8391.com
< ref href="http://218.78.213.183:880/daolianmtvfuc__________________kkkkkkkkkk//shela_believe.wmv"/ >
< param name="Artist" value="榭拉"/>
< param name="Album" value=" 蓝牙音乐网 - www.8391.com"/ >
< param name="Title" value="I Believe In Love"/ >
< /ENTRY >



确认有用数据:
歌曲名称:I Believe In Love
歌手:榭拉
歌曲路径:http://218.78.213.183:880/daolia ... //shela_believe.wmv
我们在小偷程序中只要得到以上数据就可以了
3、PHP代码编写
PHP:<  ?
/********
说明,为程序简单化,整个程序没有使用正则表达式
(我自己对这个方面也很臭,呵呵,高手别骂)
****/
//定义一个函数,对字符简单的过滤

function str($txt){
    $txt= str_replace("'","'",$txt);
    $txt= str_replace("\"","\\"",$txt);
    return $txt;
}
//初始化程序
$magic_quotes_gpc = get_magic_quotes_gpc();
$register_globals = @ini_get('register_globals');
if(!$register_globals || !$magic_quotes_gpc) {
    @extract(daddslashes($HTTP_POST_VARS));
    @extract(daddslashes($HTTP_GET_VARS));
    if(!$register_globals) {
        foreach($HTTP_POST_FILES as $key => $val) {
            $$key = $val['tmp_name'];
            ${$key.'_name'} = $val['name'];
            ${$key.'_size'} = $val['size'];
            ${$key.'_type'} = $val['type'];
        }
    }
}
if (function_exists('set_time_limit') == 1 && @ini_get('safe_mode') == 0) {
    @set_time_limit(1000);
}
//end
//为防止日后对方修改地址,把地址前部相同的提取出来
$host="http://218.78.213.183:880/daolianmtvfuc__________________kkkkkkkkkk/";
if(!$action){
echo "click here to start";
die();
}else{
 $end=3488;//结束ID
 if(!$id||$id<1)$id=1;//默认ID编号
 $url="http://mtv.8391.com/Yxwen.asp?id=".$id;    
 $str=@file_get_contents($url);//读取页面代码
 if($str){
   //利用关键字符,分割代码
   $a1=explode("value=\"",$str);//value=\"来分割字符
   //取歌手名称
   $n1=explode("\"",$a1[1]);
   $ges=str(trim($n1[0]));
   //取歌曲名称
   $g1=explode("\"",$a1[3]);
   $name=str(trim($g1[0]));
   //取歌曲地址
    $h1=explode("href=\"",$str);
     $h2=explode("\"",$h1[1]);
     $mtvurl= str(str_replace($host,"",trim($h2)));
     //添加数据库
     /********
     可根据自己的程序,适当的添加
     ********/
     
 }
 $id++;
 if($id<=$end){ echo "cleck here ";
  echo "";}
else die("program runing over"); 
}
?>

分页: 10/14 第一页 上页 5 6 7 8 9 10 11 12 13 14 下页 最后页 [ 显示模式: 摘要 | 列表 ]