??xml version="1.0" encoding="utf-8" standalone="yes"?>
错误代号 十六q制 错误cd
1001 0x800A03E9 内存不
1002 0x800A03EA 语法错误
1003 0x800A03EB 需?#8220; Q?”
1004 0x800A03EC 需?#8220; Q?”
1005 0x800A03ED 需?#8220; Q?”
1006 0x800A03EE 需?#8220; Q?”
1007 0x800A03EF 需?#8220; [ ”
1008 0x800A03F0 需?#8220; ] ”
1009 0x800A03F1 需?#8220;{ ”
1010 0x800A03F2 需?#8220; } ”
1011 0x800A03F3 需要标志符
1012 0x800A03F4 需?#8220; / ”
1013 0x800A03F5 无效?/span>
1014 0x800A03F6 非法字符
1015 0x800A03F7 字符串常量未l束
1016 0x800A03F8 注视未结?/span>
1018 0x800A03FA 函数外有"return"语句
1019 0x800A04FB 在@环外 不能?#8220;break“
1020 0x800A05FC 在@环外 不能?#8220;continue“
1023 0x800A03FF 需要十六制?/span>
1024 0x800A0400 需?while"
1025 0x800A0401 标签定义重复
1026 0x800A0402 未找到标{?/span>
1027 0x800A0403 一?switch"语句中只能有一?default"
1028 0x800A0404 需要标识符Q字W串或者数?/span>
1029 0x800A0405 需?@end"
1030 0x800A0406 条g~译已关?/span>
1031 0x800A0407 需要常?/span>
1032 0x800A0408 需?@"
1033 0x800A0409 需?"catch"
1034 0x800A040A 需?var"
1035 0x800A041B "Throw" 的后面必跟一个表辑ּQ且在同一
源代码行?/span>
private int curPage;//当前|
private int maxPage;//最大页?br />
private int maxRowCount;//总记录数
private int pageSize=2;//每页昄的记录数
private DBResult db;//记录集对?br />
private String httpfile;//当前地址栏的文gQ即具体的jsp文g
private String cif;//选择的查询字D?br />
private String ccif;//选择的查询运符
private String qvalue;//查询关键?br />
private String countSql=null;//用来存储select countQ?Q。。。。语?br />
private String topSql=null;//用来存储select top2.。。。语?br />
private String nowPage=null;//初始化当前页curPage变量Q即获得当前늚具体号
private String str_parameter;//在做页Ӟ传递除pages外的其他参数
private String andor;//查询的与/或条?br />
private String sdate;//查询其实旉
private String edate;//查询l束旉
private String paixu;//排序Ҏ(gu)
private String orderby;//排序条g
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);//获取记录LQ即所要查询记录的总行
}
//余数?则总页?两数整除的结果,若不?则总页?两数整除l果+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;//前一?br />
int next=this.curPage+1;//后一?br />
str=str+"<font style='font-size:10pt'>总计<font color='red'>"+this.getMaxRowCount()+
"</font>条记录,"+"“?lt;font color='red'>"+this.getMaxPage()+"</font>?#8221;";
str=str+" ”<font color='red'>"+this.pageSize+"</font>??#8221;当前?lt;font color='red'>"+
this.getMaxPage()+"</font>?amp;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+">上一?lt;/A>";
else
str=str+"上一?;
if(this.curPage<this.maxPage)
str=str+"<A href="+this.httpfile+"?pages="+next+str_parameter+">下一?lt;/A>";
else
str=str+"下一?;
if(this.maxPage>1&&this.curPage!=this.maxPage)
str=str+"<A href="+this.httpfile+"?pages="+this.maxPage+str_parameter+">N</A>";
else
str=str+"N</font>";
//在页面蟩转间讄隐藏表单Q来保存不同的请?br />
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;
}
//Ҏ(gu)不同条g获取不同查询前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;
}
//Ҏ(gu)不同条g获取不同的计记录L的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;
}
//Ҏ(gu)不同条g和不同的起始日期和结束日期获得不同的计算记录L的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;
}
//Ҏ(gu)不同条g和不同的起始日期和结束日期获得不同的查询Q前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;
}
//子查询中得到从v始日期到l束日期q段旉所有不重复的spidQ商品idQ,q返回不重复的spid的L
//其中spid是一个数据库中一张表中的一个属性(一列)(j)Q元l(一行)(j)
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;
}
}
/**
* @author huangqin
*
*/
public class DBConn {
public static synchronized Connection getConnection() throws Exception{
try{
Context initCtx=new javax.naming.InitialContext();//获取JNDI初始上下文对?br />
//在JNDI命名I间javaQcomp/envD里获得上下文对?br />
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{//一定要抛出异常Q否则报?br />
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();
}
}
}
数据源接口java.sql.DataSource的一些方法如下:(x)
getConnectionQ)(j)Q获得一个Connection对象?br />
getConnectionQString usernameQString passwordQ;获得一个带有用户名和密码的Connction对象?br />
getLongWriterQ)(j)Q从DataSource中获得LongWriter对象Q它是PrinterWriter的实?br />
setLongWriterQPrintWriter outQ:(x)讄Datasource的LongWriter
getLOginTimeoutQ)(j):获得DataSource试q接数据库的最大时?br />
SetLoginTimeout(int seconds):讄DataSource试q接数据库的最大时?br />
public class MyString
{
//对字W串q行GBK~码
public static String toChinese(String strvalue){
try{
if(strvalue=null){
return ;;;
}
else{
strvalue=new String(strvalue。getBytes("ISO8859_1"),"GBK");
return strvalueQ?br />
}
}catch(Exception e){
return "";
}
}
}
//对输入的字符串过滤sql注入
public static String StringtoSql(String str){
str=nullToStringQstr,"");
try{
str=str.trim().replace("\",(char)1);
}catch(Exception e){
return "";
}
return str;
}
//d数据库中数据Ӟqo(h)sql注入
public static String SqltoString(String str){
str=nullToString(str,"");
try{
str=str.replace((char)1,"\").trim();
}catch(Exception e){
return "";
}
return str;
}
//对字W串q行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;
}
//判断用户输入的字W是数字q是字母
public static boolean isIDQString str){
if(strQ?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字符q行转换
public static final String escapeHTML Tags(String input){
if(input==null||input.length()==0){
return inputQ}
StringBuffer buf=new StringBuffer(input.length());
char ch='';
for(int i=0;i<input.length();i++){
ch=input.charAt(i);
if(ch=='<'){
buf.append("<");
}else if(ch=='>'){
buf.append(">");
}else{
buf.append(ch); }
}
return buf.toString();
}
//对SQL语句中输入的ID行处?br />
public static final String SqlToLink(String str){
str=StringUtils.nullToString(str,"");
if("".equals(str)){
str="LIKE '%'";
}else{
str=("LIKE '%"+str+"%'");}
return str;
}
}
下面是用JS来验证输入数据的合法性:(x)
<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("误入h(hun)?);
myform.price.focus();
return;
}
myform.submit();
}
</script>