⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbiofficecomponent.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:
/*
 * DbIofficeComponent.java
 *
 * Created on 2001年7月13日, 下午3:32
 */

package com.gs.db.dbimp;

import  com.gs.db.*;
import java.sql.*;
import java.util.*;
import java.io.*;

/**
 *
 * @author  administrator
 * @version 
 */
public class DbIofficeComponent  implements IofficeComponent {
    public static final String SAVE_COMPONENT =
        "UPDATE iofficecomponent SET agentclass=?, entryurl=?, displayname=?, weight=?, desktop=?, status=?, isdefault=? WHERE componentname=?";
    
    String name,displayName, entryURL, agentClassName;
    int status;
    int weight;
    int desktop;
    int isDefault;
    
    IofficeComponentAgent agent = null;
    

    /** Creates new DbIofficeIofficeComponent */
    protected DbIofficeComponent(    String name,
                String displayName, String entryURL, String agentClassName,
                int status, int weight, int desktop, int isDefault)
    {
        this.name = name;
        this.displayName = displayName;
        this.entryURL = entryURL;
        this.agentClassName =agentClassName;
        this.status = status;
        this.weight =weight;
        this.desktop = desktop;
        this.isDefault = isDefault;
        
        /*
        try {
           agent = (IofficeComponentAgent)((Class.forName(agentClassName)).newInstance() );
        }
        catch ( Exception e )
        {
            //agent = null;
        }
         */
    }
    
    public Object getAgentInstance()
    {
        return agent;   //must return null, we donnot need to make a real instance here
    }

    public String getName() {
        return name;
    }
    
    /**
     * return the DisplayName  used to  denote the component in GUI or WWWPAGE
 */
    public String getDisplayName() {
        return displayName;
    }
    
    /**
     * Set the DisplayName  used to  denote the component in GUI or WWWPAGE
 */
    public void setDisplayName(String dispName) throws UnauthorizedException {
        this.displayName = dispName;
        saveToDb();
    }
    
    /**
     * return the URL to entry the component services
 */
    public String getEntryURL() {
        return this.entryURL;
    }
    
    /**
     * Set the URL to entry the component services
 */
    public void setEntryURL(String url) throws UnauthorizedException {
        this.entryURL = url;
        saveToDb();
    }
    
    /**
     * get the importance of the component
     * @return 0..99 , the larger the more important
 */
    public int getWeight() {
        return this.weight;
    }
    
    /**
     * Set the importance of the component
     * @return 0..99 , the larger the more important
 */
    public void setWeight(int weight) throws UnauthorizedException {
        this.weight = weight;
         saveToDb();       
    }
    
    /**
     * get which desktop the component belongs to 
     * @return  1: public  2:personal
 */
    public int getDesktop() {
        return this.desktop;
    }
    
    /**
     * set which desktop the component belongs to 
     * @return  1: public  2:personal
 */
    public void setDesktop(int desktop) throws UnauthorizedException {
        this.desktop = desktop;
         saveToDb();               
    }
    
    /**
     * Tells if the component is active
 */
    public boolean isActive() {
        return this.status == 1;
    }
    
    /**
     * Activate or Deactivate the component 
 */
    public void activate(boolean flag) throws UnauthorizedException {
        this.status = flag? 1:0;
        saveToDb();
    }
    
    public boolean isDefaultAccessible( ) 
    {
        return 1==isDefault;
    }
    
    public void setDefaultAccessible( boolean flag ) throws UnauthorizedException 
    {
        this.isDefault = flag? 1:0;
        saveToDb();
    }
    /**
     * return the agent class name 
 */
    public String getAgentClassName() {
        return this.agentClassName;
    }
    
    /**
     * set the agent class name
 */
    public void setAgentClassName(String className) throws UnauthorizedException {
        this.agentClassName = className;
        saveToDb();
    }
    
    
    private void saveToDb()
    {
        /*
        CREATE TABLE iofficeIofficeComponent (
	componentName		VARCHAR(80) NOT NULL,
	agentClass 	VARCHAR(255) 
	entryURL 	VARCHAR(255) NOT NULL,
	displayName	VARCHAR(80) NOT NULL,
	weight 		INT,
	desktop		INT NOT NULL,
	status 		INT NOT NULL,
	PRIMARY KEY( componentName )
);
         */
       // "UPDATE iofficeIofficeComponent SET agentClass=?, entryURL=?, displayName=?, weight=?, desktop=?, status=? WHERE componentName=? "
        Connection con = null;
        PreparedStatement pstmt = null;
        //sj<
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(SAVE_COMPONENT);
            pstmt.setString(1, this.agentClassName);
            pstmt.setString(2, this.entryURL);
            pstmt.setString(3, this.displayName);
            pstmt.setInt(4, weight);
            pstmt.setInt(5, desktop);
            pstmt.setInt(6, status);
            pstmt.setInt(7, isDefault);
            pstmt.setString( 8, this.name);
       
            pstmt.executeUpdate();
        }
        //>sj
        
        catch( SQLException sqle ) {
            System.err.println( "SQLException in DbIofficeComponent.java:saveToDb(): " + sqle );
            sqle.printStackTrace();
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -