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

📄 jahiafieldutilsdb.java

📁 java 写的一个新闻发布系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//////  JahiaFieldUtilsDB//  EV      05.01.2001//////  db_get_all_fields_id                                -> ids vector//  db_get_field_ids_in_page( pageID )                  -> ids vector//  db_get_all_field_definition_ids()                   -> ids vector//  db_get_field_id( fieldName, pageID )                -> id//package org.jahia.services.fields;import java.sql.*;                      // ResultSetimport java.util.*;                     // Vectorimport org.jahia.utils.*;           // JahiaConsoleimport org.jahia.settings.*;        // SettingsBeanimport org.jahia.data.*;import org.jahia.data.fields.*;     // JahiaField, FieldTypes, LoadFlagsimport org.jahia.services.pages.*;  // JahiaPageimport org.jahia.params.*;          // ParamBeanimport org.jahia.sharing.*;         // JahiaDataSourceManagerimport org.jahia.registries.*;      // ServicesRegistryimport org.jahia.services.files.*;  // Jahia Files Servicesimport org.jahia.services.fields.*; // Jahia Fields Servicesimport org.jahia.services.applications.*; // Jahia Applications Serviceimport org.jahia.exceptions.JahiaException;public class JahiaFieldUtilsDB{    /***        * constructor        *        */    public JahiaFieldUtilsDB()    {    } // end constructor    /***        * gets all the fields ids        *        * @return       a Vector if ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_all_fields_id()    throws JahiaException    {        Vector result = new Vector();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        JahiaField theField = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT id_jahia_fields_data FROM jahia_fields_data";            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(55);            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("id_jahia_fields_data"));                result.addElement (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_fields_id : " + se.getMessage();            JahiaConsole.println( "JahiaFieldsDB", errorMsg + " -> BAILING OUT" );            JahiaException je = new JahiaException(   "Cannot load fields from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_fields_id : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return result;    } // end db_get_all_fields_id    /***        * gets all the fields ids for a gived site        *        * @param		siteID        * @return       a Vector if ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_all_fields_id(int siteID)    throws JahiaException    {        Vector result = new Vector();        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        JahiaField theField = null;        Integer nb_to_insert;        try {            String sqlQuery = "SELECT DISTINCT id_jahia_fields_data FROM jahia_fields_data where jahiaid_jahia_fields_data=" + siteID;            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(55);            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next())            {                nb_to_insert = new Integer (rs.getInt("id_jahia_fields_data"));                result.addElement (nb_to_insert);            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_all_fields_id : " + se.getMessage();            JahiaConsole.println( "JahiaFieldsDB", errorMsg + " -> BAILING OUT" );            JahiaException je = new JahiaException(   "Cannot load fields from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.ERROR );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_all_fields_id : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return result;    } // end db_get_all_fields_id    /***        * gets the field ids in the specified page        *        * @param        pageID              the page ID        * @return       a Vector if field list ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_field_ids_in_page( int pageID )    throws JahiaException    {        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Vector fieldIDs = new Vector();        try {            String sqlQuery = "SELECT id_jahia_fields_data FROM jahia_fields_data ";            sqlQuery += "WHERE ((pageid_jahia_fields_data=" + pageID + ") ";            sqlQuery += "AND (ctnid_jahia_fields_data=0)) ";            sqlQuery += "ORDER BY id_jahia_fields_data ASC";            dbConn = ServicesRegistry.getInstance().getDBPoolService().getConnection(56);            stmt = dbConn.createStatement();            rs = ServicesRegistry.getInstance().getDBPoolService().executeQuery( stmt,sqlQuery );            while (rs.next()) {                fieldIDs.add( new Integer(rs.getInt("id_jahia_fields_data")) );            }        } catch (SQLException se) {            String errorMsg = "Error in db_get_field_ids_in_page : " + se.getMessage();            JahiaConsole.println( "JahiaFieldUtilsDB", errorMsg + " -> BAILING OUT" );            throw new JahiaException(   "Cannot load fields from the database",                                        errorMsg, JahiaException.DATABASE_ERROR, JahiaException.CRITICAL );        } finally {            try {                ServicesRegistry.getInstance().getDBPoolService().freeConnection(dbConn);                if ( stmt != null ) stmt.close();            } catch ( SQLException ex ) {                 JahiaException je = new JahiaException(   "Cannot free resources",                                        "db_get_field_ids_in_page : cannot free resources",                                        JahiaException.DATABASE_ERROR, JahiaException.WARNING );            }        }        return fieldIDs;    } // end db_get_field_ids_in_page    /***        * gets the field ids in the specified page        *        * @param        pageID              the page ID        * @return       a Vector if field list ids        *        * @exception   throws a critical JahiaException if SQL error        * @exception   throws a warning JahiaException if cannot free resources        *        */    public Vector db_get_pagefield_ids_in_page( int pageID )    throws JahiaException    {        Connection dbConn = null;        Statement stmt = null;        ResultSet rs = null;        Vector fieldIDs = new Vector();        try {            StringBuffer buf = new StringBuffer();            buf.append("SELECT id_jahia_fields_data FROM jahia_fields_data ");            buf.append("WHERE ((pageid_jahia_fields_data=");            buf.append(pageID);

⌨️ 快捷键说明

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