storequeryAction.java
上传用户:flow_meter
上传日期:2022-03-21
资源大小:40k
文件大小:1k
- package sql_lab;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.eclipse.jface.action.Action;
- import org.eclipse.swt.widgets.Text;
- public class storequeryAction extends Action {
- public storequeryAction(){
- super();
- this.setText("查看所有商店信息(&S)");
- this.setToolTipText("查看所有商店信息");
- }
- public void run(){
- if(MainWindow.log==false){
- Text content=MainWindow.getApp().getContent();
- content.append("请您先登陆n");
- return ;
- }
- String str="select * from "+sqlManager.tb_store;
- sqlManager sql=sqlManager.getSqlManager();
- ResultSet set=sql.executeQuery(str);
- Text content=MainWindow.getApp().getContent();
- boolean flag=false;
- String s="***********************************商店信息查询结果**********************************n";
- try{
- while(set.next()){
- flag=true;
- content.append(s);
-
- content.append("商店ID: "+set.getInt(1)+" n");
- content.append("商店名称: "+set.getString(2)+"n");
- content.append("商店地址: "+set.getString(3)+"n");
- content.append("店主: "+set.getString(4)+"n");
- content.append("商店电话: "+set.getString(5)+"n");
- }
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- content.append(s);
- if(flag==false)content.append("查询结果为空n");
- }
- }