java running_Running

/**

*

*/

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="

";

int prev=this.curPage-1;//前一頁

int next=this.curPage+1;//后一頁

str=str+"總計"+this.getMaxRowCount()+

"條記錄,"+"“共"+this.getMaxPage()+"頁”";

str=str+" ”"+this.pageSize+"條/頁”當前頁"+

this.getMaxPage()+"頁?";

if(this.curPage>1)

str=str+"首頁";

else

str=str+"首頁";

if(this.curPage>1)

str=str+"上一頁";

else

str=str+"上一頁";

if(this.curPage

str=str+"下一頁";

else

str=str+"下一頁";

if(this.maxPage>1&&this.curPage!=this.maxPage)

str=str+"尾頁";

else

str=str+"尾頁";

//在頁面跳轉間設置隱藏表單,來保存不同的請求

str=str+"轉到頁"+

"" +

"input type='hidden' name='cif' value='"+this.cif+

"'>

";

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+"

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+"

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;

}

}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/533961.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/533961.shtml
英文地址,請注明出處:http://en.pswp.cn/news/533961.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

python停用詞表_多版本中文停用詞詞表 + 多版本英文停用詞詞表 + python詞表合并程序...

文章簡介與更新記錄如果你只想獲取中文停用詞此表,請直接到文章結尾下載項目文件,其中包括三個中文停用詞詞表,一個英文停用詞詞表和一個合并詞表的.py文件2017/07/04 創建文章,上傳文件2017/07/04 更新了合并代碼,添加了新的中文停用詞表(哈工大擴展版本)和一個新的停用詞表,現…

mysql collect_set_hive列轉行 (collect_set())

一、問題hive如何將a b 1a b 2a b 3c d 4c d 5c d 6變為&#xff1a;a b 1,2,3c d 4,5,6二、數據test.txta b 1a b 2a b 3c d …

python編寫遞歸函數和非遞歸函數、輸出斐波那契數列_分別用非遞歸和遞歸的方法編寫函數求斐波那契數列第n項。斐波那契數列1,1,2,3,5,8,13,…...

展開全部/**已知Fibonacci數列&#xff1a;1,1,2,3,5,8,……&#xff0c;F(1)1&#xff0c;F(2)1&#xff0c;F(n)F(n-1)F(n-2)*/#include #include typedef long long int int64;//方法1&#xff0c;遞歸法int64 Fibonacci(int n){int64 sum;if(n<0){printf("參數值e6…

python3.6安裝ipython_centos6.5下安裝python3.6、pip、ipython

一.先更換系統源為了下載順暢一般都會更改為國內源。1 cd /etc/yum.repos.d/2 wget http://mirrors.163.com/.help/CentOS6-Base-163.repo #下載網易源3 mv CentOS-Base.repo CentOS-Base.repo.ori #備份源4 mv CentOS6-Base-163.repo CentOS-Base.repo #把網易源更改為默認源二…

java 多線程的同步問題_java多線程解決同步問題的幾種方式,原理和代碼

wait()/notify()方法await()/signal()方法BlockingQueue阻塞隊列方法PipedInputStream/PipedOutputStream阻塞隊列的一個簡單實現&#xff1a;public class BlockingQueue {private List queue new LinkedList();private int limit 10;public BlockingQueue(int limit){this…

python期末大作業_大一期末考試很重要,考得好不僅有機會有錢拿,還有機會換專業...

現階段很多高校放寒假的時間已經公布&#xff0c;這也就意味著&#xff0c;大學期末考試即將到來。對于大一新生來說&#xff0c;大學的期末考試是比較新鮮的&#xff0c;因為大家都沒有經歷過。經歷過大學考試的學生&#xff0c;都知道大學的大概學習模式&#xff0c;一般情況…

java http 302重定向_Java 純HTTP請求 禁止302自動重定向

Java 純HTTP Get請求獲取響應內容&#xff0c;如果發生302重定向&#xff0c;繼而模擬請求域獲取重定向后的響應內容。關鍵點&#xff1a;設置conn.setInstanceFollowRedirects為false即可示例代碼public static void main(String[] args) {try {StringBuffer buffer new Stri…

python 且_Pyface庫:一個基于pyqt、pyside、wx且簡化的python的GUI

1 說明&#xff1a;1.1 Pyface庫由大名鼎鼎的enthought出品。1.2 介紹&#xff1a;1.2.1 英文&#xff1a;traits-capable windowing framework.The pyface project contains a toolkit-independent GUI abstraction layer, which is used to support the "visualization&…

java方法的參數類型_Java 基礎 14 方法的重載 與 方法參數類型詳解

1.1 方法重載的概述和特點方法重載概述在同一個類中&#xff0c;允許存在一個以上的同名方法&#xff0c;只要它們的參數個數或者參數類型不同即可。方法重載特點與返回值類型無關&#xff0c;只看方法名和參數列表在調用時&#xff0c;虛擬機通過參數列表的不同來區分同名方法…

crv儀表上的i是什么指示燈_汽車打不著火是怎么回事,儀表盤汽車發動機故障燈亮是什么情況故障指示燈圖解大全集...

如果打不著火&#xff0c;那有可能是起動機壞了&#xff0c;有可能是電池沒電了&#xff0c;有可能是電路出現了問題&#xff0c;還有可能是點火系統出現了問題。汽車發動機的點火系統主要部件是火花塞和點火線圈&#xff0c;火花塞是一個需要定期更換的易損件。如果火花塞長時…

python極簡教程_Python 極簡教程(六)運算符

運算符&#xff0c;我們日常生活中使用的加減乘除&#xff0c;都是運算符的一種。當然這種一般我們稱為算術運算符&#xff0c;用于處理數字運算的。但是在計算機語言中&#xff0c;還有很多的運算符。用于處理不用的情況。主要有以下幾類&#xff1a;算術運算符比較運算符邏輯…

python函數可變長參數_day14 Python函數之可變長參數

函數參數1.形參變量只有在被調用時才分配內存單元&#xff0c;在調用結束時&#xff0c;即刻釋放所分配的內存單元。因此&#xff0c;形參只在函數內部有效。函數調用結束返回主調用函數后則不能再使用該形參變量2.實參可以是常量、變量、表達式、函數等&#xff0c;無論實參是…

ubuntu 安裝java jdk_「ubuntu安裝jdk」Ubuntu安裝jdk8的兩種方式 - seo實驗室

ubuntu安裝jdk安裝方式&#xff1a;1)&#xff1a;通過ppa(源) 方式安裝.2)&#xff1a;通過官網安裝包安裝.JDK官網下載地址一&#xff1a;使用ppa(源)方式安裝&#xff1a;1)&#xff1a;添加ppa源sudo add-apt-repository ppa:webupd8team/javasudo apt-get update2)&#x…

restful風格_什么是RESTful風格的API設計?

隨著移動互聯網的興起&#xff0c;RESTful風格的API設計也隨之流行起來&#xff0c;但我們說了那么多RESTful設計&#xff0c;它到底是什么&#xff1f;本篇文章帶大家來了解一下它的真實面目。RESTful概念首先&#xff0c;我們需要明確的是RESTful&#xff0c;它是一個理念&am…

java jdbc 增刪改封裝_JAVA JDBC 常規增刪改查簡單封裝

JAVA JDBC 常規增刪改查簡單封裝,可滿足大多基本要求作用&#xff1a;1&#xff0c; 查詢列表是直接返回List對象&#xff0c;不必再遍歷&#xff1b;2&#xff0c; 單條查詢直接返回對象&#xff1b;3&#xff0c; 執行sql僅需一個方法搞定&#xff1b;package com.Main.Tools…

python wget安裝_Macbook系統環境安裝wget的2個方法 - 傳統包及Homebrew安裝

考慮到自身項目的拓展需要&#xff0c;朋友建議學習Python爬蟲這樣對于做大數據采集有較大的幫助&#xff0c;老蔣雖然每天也都接觸一些腳本和程序的修改&#xff0c;但是并沒有專業和系統的學習某一項編程。所以還是準備陸續的學習Python語言&#xff0c;無論有沒有基礎&#…

java 程序找錯_java代碼找錯

展開全部你試一下這個行不行&#xff0c;輸入的時候是數字e69da5e6ba903231313335323631343130323136353331333335313138,數字,數字;數字,數字。。。。。的格式&#xff0c;你把我注釋的那個輸入行(String stInput input.next();)的注釋去掉&#xff0c;把我字符串寫死的那行(…

zookeeper 分布式鎖_關于redis分布式鎖,zookeeper分布式鎖原理的一些學習與思考

編輯&#xff1a;業余草來源&#xff1a;https://www.xttblog.com/?p4946首先分布式鎖和我們平常講到的鎖原理基本一樣&#xff0c;目的就是確保&#xff0c;在多個線程并發時&#xff0c;只有一個線程在同一刻操作這個業務或者說方法、變量。在一個進程中&#xff0c;也就是一…

Java線程怎么發送消息_Java客戶端Socket如何能在阻塞線程下收到服務端發送來的消息?...

最近在寫Socket客戶端的時候遇到點問題客戶端在創建時創建了2個線程一個監聽鍵盤輸入事件&#xff0c;使用的是buffered&#xff0c;當檢測到輸入完成時寫入流發送給服務端。String content "";while (!(content bufferedReader.readLine()).equals("exit&quo…

python函數參數傳遞機制_Python 學習筆記(一) 理解Python的函數傳參機制

對于剛接觸Python不久的新手&#xff0c;Python的函數傳參機制往往會讓人迷惑。學過C的同學都知道函數參數可以傳值或者傳地址。比如下面這段代碼點擊(此處)折疊或打開void func(int input) {input 100;}int a 0;func(a);printf("%d", a);結果應該是打印0&#xff…