很奇怪,自從我上次拆了一下內存條 后,有時我打開IE時會彈出一個錯誤對話框,發出一下提示:
1:
出現了運行時間錯誤。是否要進行調試?
行:1616
錯誤:未結束的字符串常量
2:出現了運行時間錯誤。
是否要調試?
行:1443
錯誤:缺少對象
這是什么原因導致IE發出這樣的錯誤警告呢?剛開始我還以為是我的內存條壞了,一位是我內存條上的存儲顆粒被我搞掉了一些,因為上次我看到內存上有許多灰塵,就用布去抹灰塵的。
其實是我把的IE中“Internet選項”中的“高級”下的 “禁止腳本調試Internet Explorer” 這一欄的勾去掉了,那就代表我允許調試IE了,所以腳本在調試IE時就報錯了。
為了避免這種情況,應該將一項勾上。
置頂隨筆
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" 的后面必須跟一個表達式,且在同一
源代碼行上
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>頁 ";
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;
}
}
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();
}
}
}
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;
}
}
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嘗試連接數據庫的最大時間
//其中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>
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">
<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>
很奇怪,自從我上次拆了一下內存條 后,有時我打開IE時會彈出一個錯誤對話框,發出一下提示:
1:
出現了運行時間錯誤。是否要進行調試?
行:1616
錯誤:未結束的字符串常量
2:出現了運行時間錯誤。
是否要調試?
行:1443
錯誤:缺少對象
這是什么原因導致IE發出這樣的錯誤警告呢?剛開始我還以為是我的內存條壞了,一位是我內存條上的存儲顆粒被我搞掉了一些,因為上次我看到內存上有許多灰塵,就用布去抹灰塵的。
其實是我把的IE中“Internet選項”中的“高級”下的 “禁止腳本調試Internet Explorer” 這一欄的勾去掉了,那就代表我允許調試IE了,所以腳本在調試IE時就報錯了。
為了避免這種情況,應該將一項勾上。
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);
}
}
}
if(string==null){
str1="";
}else
{
try{
string=string.replaceAll("<","&It;");
string=string.replaceAll(">",“>”);
string=string.replaceAll(""," ");
string=string.replaceAll("\r\n","<br>");
}catch(Exception e){
e.printStackTrace(System.err);
}
}
return string;
}