置顶随笔

很奇怪,自从我上次拆了一下内存条 后,有时我打开IE时会弹出一个错误对话框,发出一下提示:
1:
出现了运行时间错误。是否要进行调试?
 行:1616
错误:未结束的字符串常量

2:出现了运行时间错误。
是否要调试?
行:1443
错误:缺少对象

这是什么原因导致IE发出这样的错误警告呢?刚开始我还以为是我的内存条坏了,一位是我内存条上的存储颗粒被我搞掉了一些,因为上次我看到内存上有许多灰尘,就用布去抹灰尘的。
其实是我把的IE中“Internet选项”中的“高级”下的 “禁止脚本调试Internet Explorer” 这一栏的勾去掉了,那就代表我允许调试IE了,所以脚本在调试IE时就报错了。
为了避免这种情况,应该将一项勾上

posted @ 2008-12-08 22:42 Running 阅读(256) | 评论 (0)编辑 收藏

2008年12月17日

 

 

错误代号       十六进制      错误类型

1001           0x800A03E9   内存不足

1002           0x800A03EA   语法错误

1003           0x800A03EB   需要“ : ”

1004           0x800A03EC   需要“ ; ”

1005           0x800A03ED   需要“ ( ”

1006           0x800A03EE   需要“ ) ”

1007           0x800A03EF   需要“ [ ”

1008           0x800A03F0   需要“ ] ”

1009           0x800A03F1   需要“{ ”

1010           0x800A03F2   需要“ } ”

1011           0x800A03F3   需要标志符

1012           0x800A03F4   需要“ / ”

1013           0x800A03F5   无效数

1014           0x800A03F6   非法字符

1015           0x800A03F7   字符串常量未结束

1016           0x800A03F8   注视未结束

1018           0x800A03FA   函数外有"return"语句

1019           0x800A04FB   在循环外 不能有“break“

1020           0x800A05FC   在循环外 不能有“continue“

1023           0x800A03FF   需要十六制数

1024           0x800A0400   需要"while"

1025           0x800A0401   标签定义重复

1026           0x800A0402   未找到标签

1027           0x800A0403   一条"switch"语句中只能有一个"default"

1028           0x800A0404   需要标识符,字符串或者数字

1029           0x800A0405   需要"@end"

1030           0x800A0406   条件编译已关闭

1031           0x800A0407   需要常数

1032           0x800A0408   需要"@"

1033           0x800A0409   需要 "catch"

1034           0x800A040A   需要"var"

1035          0x800A041B   "Throw" 的后面必须跟一个表达式,且在同一

                                   源代码行上

posted @ 2008-12-17 22:37 Running 阅读(249) | 评论 (0)编辑 收藏

2008年12月11日

/**
 *
 */
package test;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
 * @author huangqin
 *
 */
public class QuestString {

 private int curPage;//当前页数
 private int maxPage;//最大页数
 private int maxRowCount;//总记录数
 private int pageSize=2;//每页显示的记录数
 private DBResult db;//记录集对象
 private String httpfile;//当前地址栏的文件,即具体的jsp文件
 private String cif;//选择的查询字段
 private String ccif;//选择的查询运算符
 private String qvalue;//查询关键字
 private String countSql=null;//用来存储select count(*)。。。。语句
 private String topSql=null;//用来存储select top2.。。。语句
 private String nowPage=null;//初始化当前页curPage变量,即获得当前页的具体页号
 private String str_parameter;//在做翻页时,传递除pages外的其他参数
 private String andor;//查询的与/或条件
 private String sdate;//查询其实时间
 private String edate;//查询结束时间
 private String paixu;//排序方法
 private String orderby;//排序条件
 public QuestString() throws Exception{
  db=new DBResult();
 }
 public void setCurPage(int curPage){
  this.curPage=curPage;
 }
 public void setQuerySql(String httpfile,String pages,String strCount){
  this.httpfile=httpfile;
  this.nowPage=pages;
  this.countSql=strCount;
  try{
   querySql(countSql);
  }catch(Exception e){
   e.printStackTrace();
  }
 }
 public  void querySql(String countSql)throws SQLException {
  // TODO Auto-generated method stub

  if(this.nowPage==null){
   this.curPage=1;
  }else{
   this.curPage=Integer.parseInt(this.nowPage);
   if(this.curPage<1){
    this.curPage=1;
   }
  }
  ResultSet rsCount=db.getResult(countSql);
  if(rsCount.next()){
   this.maxRowCount=rsCount.getInt(1);//获取记录总数,即所要查询记录的总行
  }
  //余数为0则总页数=两数整除的结果,若不为0则总页数=两数整除结果+1
  this.maxPage=(this.maxRowCount%this.pageSize==0)?(this.maxRowCount/this.pageSize):
   (this.maxRowCount/this.pageSize+1);
  if(this.curPage>this.maxPage){
   this.curPage=this.maxPage;
  }
  rsCount.close();
 }
 public String pageFooter()
 {
  String str="<form action="+this.httpfile+"name=formBean method=post>";
  int prev=this.curPage-1;//前一页
  int next=this.curPage+1;//后一页
  
  str=str+"<font style='font-size:10pt'>总计<font color='red'>"+this.getMaxRowCount()+
  "</font>条记录,"+"“共<font color='red'>"+this.getMaxPage()+"</font>页”";
  str=str+" ”<font color='red'>"+this.pageSize+"</font>条/页”当前页<font color='red'>"+
  this.getMaxPage()+"</font>页&nbsp;";
  if(this.curPage>1)
   str=str+"<A href="+this.httpfile+"?pages=1"+str_parameter+">首页</A>";
  else
   str=str+"首页";
  if(this.curPage>1)
   str=str+"<A href="+this.httpfile+"?pages="+prev+str_parameter+">上一页</A>";
  else
   str=str+"上一页";
  if(this.curPage<this.maxPage)
   str=str+"<A href="+this.httpfile+"?pages="+next+str_parameter+">下一页</A>";
  else
   str=str+"下一页";
  if(this.maxPage>1&&this.curPage!=this.maxPage)
   str=str+"<A href="+this.httpfile+"?pages="+this.maxPage+str_parameter+">尾页</A>";
  else
   str=str+"尾页</font>";
  //在页面跳转间设置隐藏表单,来保存不同的请求
  str=str+"转到<input type='text' name='pages' size=2>页"+
  "<input type='hidden' name='ccif' value='"+this.ccif+"'>" +
    "input type='hidden' name='cif' value='"+this.cif+
    "'><input type='hidden' name='qvalue' value='"+this.qvalue+
    "'><input type='hidden' name=andor' value='"+this.andor+
    "'><input type='hidden name='sdate' value='"+this.sdate+
    "'><input type='hidden name='edate' value='"+this.edate+
    "'><input type='hidden' name='orderby' value='"+this.orderby+
    "'><input type='hidden' name='paixu' value='"+this.paixu+
    "'><input type='submit' name='submit' value='go'></form>";
  return str;
 }
 private int getMaxPage() {
  // TODO Auto-generated method stub  
  return maxPage;
 }
 private int getMaxRowCount() {
  // TODO Auto-generated method stub
  return maxRowCount;
 }
 //根据不同条件获取不同查询前N条的SQL语句
 public String getString(String table){
  
  if(ccif.equals("="))
  {
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table+"where"+
   ""+cif+"="+"'"+qvalue+"'";
   return strSql;
  }
  else if(ccif.equals("LIKE"))
  {
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table+
   "where"+""+cif+""+"like"+""+"'%"+qvalue+"%'";
   return strSql;
  }
  else if(ccif.equals("ALL")){
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table;
   return strSql;
  }
  else if(ccif.equals("<"))
  {
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table+
   "where"+cif+"<'"+qvalue+"'";
   return strSql;
  }
 return null;
 
 }
 //根据不同条件获取不同的计算记录总数的SQL语句
 public String getCount(String table){
  
  if(ccif.equals("=")){
   String strSql="select count(*) from"+table+"where"+""+cif+"="+"'"+qvalue+"'";
   return strSql;
  }
  else if(ccif.equals("LIKE")){
   String strSql="select count(*) from"+table+"where"+""+cif+""+"like"+""+"'%"+qvalue+"%'";
   return strSql;
  }
  else if(ccif.equals("ALL")){
   String strSql="select count(*) from"+table;
   return strSql;
  }
  else if(ccif.equals("<")){
   String strSql="select count(*) from "+table+"where"+cif+"<'"+qvalue+"'";
   return strSql;
  }
  return null;
  
 }
 //根据不同条件和不同的起始日期和结束日期获得不同的计算记录总数的SQL语句
 public String getDateCount(String table){
  if(ccif.equals("=")){
   String strSql="select count(*) from"+table+"where"+""+cif+"="+"'"+qvalue+"'"+
   andor+"xsdate between'"+sdate+"'and'"+edate+"'";
   return strSql;
  }
  else if(ccif.equals("LIKE")){
   String strSql="select count(*) from"+table+"where"+""+cif+""+"like"+""+"'%"+qvalue+"%'"+
   andor+"xsdate between'"+sdate+"'and'"+edate+"'";
   return strSql;
  }
  else if(ccif.equals("ALL")){
   String strSql="select count(*) from"+table;
   return strSql;
  }
  
  return null;
 }
 //根据不同条件和不同的起始日期和结束日期获得不同的查询,前N条的SQL语句
 public String getDateString(String table){
  if(ccif.equals("="))
  {
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table+"where"+
   ""+cif+"="+"'"+qvalue+"'"+andor+"xsdate between'"+sdate+"'and'"+edate+"'";
   return strSql;
  }
  else if(ccif.equals("LIKE"))
  {
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table+
   "where"+""+cif+""+"like"+""+"'%"+qvalue+"%'"+andor+"xsdate between'"+sdate+
   "'and'"+edate+"'";
   return strSql;
  }
  else if(ccif.equals("ALL")){
   String strSql="select top"+this.pageSize*this.curPage+"*from"+table;
   return strSql;
  }
  
  return null;
 }
 //子查询中得到从起始日期到结束日期这段时间所有不重复的spid(商品id),并返回不重复的spid的总数
 //其中spid是一个数据库中一张表中的一个属性(一列),元组(一行)
 public String getOrderCount(String table){
  String strSql="select count(*) from (select spid from"+table+"where xsdate between'"+
  sdate+"'and'"+edate+"'group by spid) as aa";
  return strSql;
  
  
 }
 public String getOrderString(String table){
  String strSql="select top"+this.pageSize*this.curPage+"* from tb_brand a inner join" +
    "(select spid,sum(sl)as sl,sum(je)as je"+
    "from "+table+"where xsdate between'"+sdate+"'and'"+edate+"'group by spid)"+
    "as b"+"on a.id=b.spid order by"+orderby+""+paixu;
    return strSql;
  

 }
}

posted @ 2008-12-11 20:54 Running 阅读(466) | 评论 (1)编辑 收藏
 

package test;
import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

/**
 * @author huangqin
 *
 */
public class DBConn {
 public static synchronized Connection getConnection() throws Exception{
  try{
   Context initCtx=new javax.naming.InitialContext();//获取JNDI初始上下文对象
   //在JNDI命名空间java:comp/env段里获得上下文对象
   Context envCtx=(Context)initCtx.lookup("java:comp/env");
   DataSource ds=(DataSource)envCtx.lookup("jdbc/xscj");
   return ds.getConnection();
  }catch(SQLException e){
   throw e;
  }catch(NamingException ex){
   throw ex;
  }
 }

}

package test;
import java.sql.*;
import test.DBConn;
/**
 * @author huangqin
 *
 */
public class DBResult {

 private Connection con;
 public DBResult() throws Exception{//一定要抛出异常,否则报错
  this.con=DBConn.getConnection();
 }
 public ResultSet getResult(String sql){
  try{
   Statement stmt=con.createStatement();
   ResultSet rs=stmt.executeQuery(sql);
   return rs;
  }catch(Exception e){
   return null;
  }
 }
 public void doExecute(String sql){
  try{
   Statement stmt=con.createStatement();
   stmt.executeQuery(sql);
  }catch(Exception e){}
 }
 public PreparedStatement getPreparedStatement(String sql){
  try{
   PreparedStatement pstmt=con.prepareStatement(sql);
   return pstmt;
  }catch(Exception e){
   return null;
  }
 }
 public void closeConn(){
  try{
   this.con.close();
  }catch(Exception e){
   e.printStackTrace();
  }
 }
}

posted @ 2008-12-11 20:53 Running 阅读(167) | 评论 (0)编辑 收藏
 

import java.util.*;
/**
 * @author huangqin
 *
 */
public class ShowTime {
private Date date=null;
private int yy;
private int mm;
private int dd;
private String sy;
private String sd;
private String sm;
public ShowTime(){
 date=new Date();
 yy=date.getYear()+1900;
 mm=date.getMonth()+1;
 dd=date.getDate();
 sy=String.valueOf(yy);
 sm=String.valueOf(mm);
 sd=String.valueOf(dd);
 if(sm.length()==1){
  sm="0"+sm;}
 if(sd.length()==1){
  sd="0"+sd;
 }
}
 public String getDateString(){
  return sy+sm+sd;
 }
 public String getDate(){
  return sy+"-"+sm+"-"+sd;
 }
}

 

posted @ 2008-12-11 20:51 Running 阅读(305) | 评论 (0)编辑 收藏

2008年12月10日

数据库连接池的解决方案:再应用程序启动时建立足够的数据库连接,并将这些连接组成一个
连接池,使应用程序动态的对池中的连接进行申请、使用和释放。对于多余连接池中连接数的并发请求,需要再请求队列中排队等待,并且应用程序可以根据池中连接的使用率,动态增加或减少池中的连接数。

数据源接口java.sql.DataSource的一些方法如下:

getConnection():获得一个Connection对象。
getConnection(String username,String password);获得一个带有用户名和密码的Connction对象。
getLongWriter();从DataSource中获得LongWriter对象,它是PrinterWriter的实例
setLongWriter(PrintWriter out):设置Datasource的LongWriter
getLOginTimeout():获得DataSource尝试连接数据库的最大时间
SetLoginTimeout(int seconds):设置DataSource尝试连接数据库的最大时间

posted @ 2008-12-10 22:05 Running 阅读(104) | 评论 (0)编辑 收藏
 

//其中default.htm默认已经存在
<script language="javascript" >
function intro(){
if((navigator.appVersion.indexOf("Mac")!=-1)&&
(navigator.userAgent.indexOf("MSIE")!=-1)&&
(parseInt(navigator.appVersion)=4)){
skip()
}else{
popup()
}
}
function skip(){
location.href="default.htm";
}
function popup(){
version=parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('.')-1,
navigator.appVersion.length));
if(version>=4)
version=parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('.')-1,
navigator.appVersion.length));
if(version>=4){
if(navigator.appName=="Netscape"){
Hello=window.open("default.htm","Hello","scrollbars");
Hello.focus();
}
if(navigator.appName=="Microsoft Internet Explorer"){
 window.open("default.htm","screen","fullscreen==yes");
 }
 else{
 location.href="default.htm";
 }
 }
 </script>

 

posted @ 2008-12-10 21:48 Running 阅读(456) | 评论 (0)编辑 收藏

2008年12月9日

import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;

public class MyString
{
//对字符串进行GBK编码
public static String toChinese(String strvalue){
try{
if(strvalue=null){
return ;;;
}
else{
strvalue=new String(strvalue。getBytes("ISO8859_1"),"GBK");
return strvalue;
}
}catch(Exception e){
return "";
}
}
}
//对输入的字符串过滤sql注入
public static String StringtoSql(String str){
str=nullToString(str,"");
try{
str=str.trim().replace("\",(char)1);
}catch(Exception e){
return "";
}
return str;
}
//读取数据库中数据时,过滤sql注入
public static  String SqltoString(String str){
str=nullToString(str,"");
try{
str=str.replace((char)1,"\").trim();
}catch(Exception e){
return "";
}
return str;
}
//对字符串进行Unicode编码
public static String toUnicode(String strvalue){
try{
if(strvalue==null){
return null;
}else{
strvalue=new String(strvalue.getBytes("GBK"),"ISO8895_1");
return strvalue;
}
}catch(Exception e){
return "";
}
}
//判断当前时间
public static boolean compareNowTime(String date){
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
Date d=null;
try{
d=format.parse(date);
}catch(ParseException ex){
}
if(System.currentTimeMillis()-259200000<d.getTime()){
return true;
}
return false;
}
//判断用户输入的字符是数字还是字母
public static boolean isID(String str){
if(str!=null&&str.length()>0){
if(str.charAt(0)<57&&str.charAt(0)>48)  return false;
for(int i=0;i<str.length();i++){
if(str.charAt(i)<65&&str.charAt(i)>57||str.charAt(i)>90&&str.charAt(i)<97&&
str.charAt(i)!=95||str.charAt(i)>122||str.charAt(i)<48){
return false;
}
}
return true;
}
return false;
}
//对输入数据中的HTML字符进行转换
public static final String escapeHTML Tags(String input){
if(input==null||input.length()==0){
return input;}
StringBuffer buf=new StringBuffer(input.length());
char ch='';
for(int i=0;i<input.length();i++){
ch=input.charAt(i);
if(ch=='<'){
buf.append("&lt;");
}else if(ch=='>'){
buf.append("&gt;");
}else{
buf.append(ch);  }
  }
return buf.toString();
}
//对SQL语句中输入的空值进行处理
public static final String SqlToLink(String str){
str=StringUtils.nullToString(str,"");
if("".equals(str)){
str="LIKE '%'";
}else{
str=("LIKE '%"+str+"%'");}
return str;
}
}

posted @ 2008-12-09 22:02 Running 阅读(330) | 评论 (0)编辑 收藏

2008年12月8日

假定我要处理的form中的内容如下(在此我简化了一下):
<form name="myform">
<input type="text" name="goodsName" size="8"><br>
<input type="file" name="picture" ><br>
<input type="text" name="price" size="5"><br>
<input type="submit" name="submit" value="submit">&nbsp;&nbsp;
<input type="reset" name="reset" value="reset">
</form>

下面是用JS来验证输入数据的合法性:

<script language="javascript">
function mycheck(){
if(myform.goodsName.value==""){
alert("请输入商品姓名");
myform.goodsName.focus();
return;
}
if(myform.picture.value==""){
alert("请输入图片文件的路径");
myform.picture.focus();
return;
}
if(myform.price.value==""){
alert("请输入价格");
myform.price.focus();
return;
}
myform.submit();
}
</script>

posted @ 2008-12-08 23:09 Running 阅读(799) | 评论 (1)编辑 收藏

2008年12月7日

public static Connection getConnection(){

Connection conn=null;
private  static    String dbUrl="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_shop”;
private static   String dbUser="sa";
private static String dbPwd="";
private static String dbClassName=“com.microsoft.jdbc.sqlserver.SQLServerDriver";
    //   loadProperty();//通过loadProperty方法读取properties文件中的数据库连接所需信息
            try{
                        Class.forName(dbClassName).newInstance();
                        conn=DriverManager.getConnection(dbUrl,dbUser,dbPwd);
}catch(Exception ee){
           ee.printStackTrace();
}
if(conn=null){
System.err.println("警告:DbConnectionManager.getConnection() 获得数据库连接失败。\r\n\r\n连接;类型:"+dbClassName+"\r\n连接位置:"+dbUrl+"\r\n用户/密码"+dbUser+"/"+dbPwd);
}
return conn;
}


public ResultSet  executeQuery(String sql){
try{
conn=getConnection();
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}catch(SQLException ex){
System.out.println(ex.getMessage());
}
return rs;
}



public int executeUpdate(String sql){
int result=0;
try{
conn=getConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=stmt.executeUpdate(sql);
}catch(SQLException ex){
result =0;
}try{
stmt.close();
}catch(SQLException ex1){
return result;
}

public void close(){
try{
if(rs!=null){
rs.close();
}
}catch(Exception e){
e.printStackTrace(System.err);}
try{
if(stmt!=null){
stmt.close();
}
}catch(Exception e){
e.printStackTrace(System.err);
}
try{
if(conn!=null){
conn.close();
}
}catch(Exception e){
e.printStackTrace(System.err);
}
}
}
posted @ 2008-12-07 23:31 Running 阅读(145) | 评论 (0)编辑 收藏
 
public String convertStr(String string){
if(string==null){
           str1="";
}else
            {
                       try{
                                         string=string.replaceAll("<","&It;");
                                          string=string.replaceAll(">",“&gt”);
                                           string=string.replaceAll("","&nbsp;");
                                          string=string.replaceAll("\r\n","<br>");
                                    }catch(Exception e){
                                e.printStackTrace(System.err);
                         }
                  }
return string;
}
posted @ 2008-12-07 22:48 Running 阅读(3620) | 评论 (2)编辑 收藏
仅列出标题