<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    JAVA—咖啡館

    ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術(shù),交流工作經(jīng)驗,分享JAVA帶來的快樂!本網(wǎng)站部分轉(zhuǎn)載文章,如果有版權(quán)問題請與我聯(lián)系。

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks
    Apache Torque是一個使用關(guān)系數(shù)據(jù)庫作為存儲手段的Java應(yīng)用程序持久化工具,是 Apache 的公開源代碼項目,Torque是一個開源項目,由Web應(yīng)用程序框架Jakarta Apache Turbine發(fā)展而來,但現(xiàn)在已完全獨立于Turbine。 Torque 主要包含兩部分:一部分是 Generator,它可以使用xml文件,產(chǎn)生應(yīng)用程序需要的所有數(shù)據(jù)庫資源,包括 sql 和 java 文件;另外一部分是 Runtime,提供使用這些代碼訪問數(shù)據(jù)庫的運行時環(huán)境。

    torque作為orm,我一般是自己手工編寫xml文件,通過xml文件,生成sql腳本和java對象文件,但由于在實際項目過程中,很難做到表結(jié)構(gòu)不變動,很多時間需要花在xml文件的維護和java對象文件的更換上,在幾個實際項目中使用過后,就放棄了。放棄的原因主要有:1、項目組的兄弟多數(shù)比較抵制操作java對象來進行數(shù)據(jù)庫,因為他們看不到自己比較熟悉的sql了;2、使用orm工具多少需要些時間來學(xué)習(xí)工具的使用,雖然相對于現(xiàn)在hibernate,torque還是比較簡單的;3、在項目中,也很難做到數(shù)據(jù)庫設(shè)計不變化,另外舊就是我現(xiàn)在所在公司大量使用oracle存儲過程;4、在大多數(shù)時候,項目總是由最少的人,干盡可能多的事情,所以在很多時候,你不得不放棄一些所謂的技術(shù)和理念,用最短的時間將事情搞定,你才能獲得上司的認可。尤其在我目前所在公司,一個千萬級別的項目,也僅僅是3~5個人來完成,作為項目經(jīng)理,除了要做數(shù)據(jù)庫設(shè)計、存儲過程編寫、框架搭建、新人培訓(xùn)(因為3~5個人里面也許就你一個是有經(jīng)驗的人)、硬件設(shè)備收貨、機器上架、網(wǎng)絡(luò)打通(如果你還會調(diào)試路由器,這個事情也屬于你來搞定的范疇)協(xié)調(diào)、各種外系統(tǒng)接口梳理和定義、外系統(tǒng)相關(guān)公司協(xié)調(diào),呵呵,我經(jīng)常戲虐公司的項目經(jīng)理是十項全能選手,因為你的上司還要求你要有銷售意識。
    扯遠了,如何使用torque作為orm我就不寫了,我現(xiàn)在一般使用torque作為數(shù)據(jù)庫訪問工具,如何將torque引入你的系統(tǒng)(非web應(yīng)用,獨立應(yīng)用程序),以oracle作為實際例子:
    第一步:引入包
    classes12.jar
    log4j-1.2.15.jar
    commons-beanutils-1.7.0.jar
    commons-collections-3.1.jar
    commons-configuration-1.1.jar
    commons-dbcp-1.2.2.jar(如果你還在使用commons-dbcp-1.2.2.jar以下版本作為數(shù)據(jù)庫連接池,都請更新到commons-dbcp-1.2.2.jar)
    commons-lang-2.1.jar
    commons-logging-1.0.4.jar
    commons-pool-1.2.jar
    commons-discovery-0.2.jar
    torque-3.2.jar
    village-2.0-dev-20030825.jar

    第二步:配置torque.properties 和 log4j.properties ,配置文件我一般放在classes目錄下
    1、torque.properties

    # -------------------------------------------------------------------
    # $Id: Torque.properties,v 1.11.2.2 2004/08/24 04:14:32 seade Exp $
    #
    # This is the configuration file for Torque.
    #
    # Note that strings containing "," (comma) characters must backslash
    # escape the comma (i.e. '\,')
    #
    # -------------------------------------------------------------------

    torque.applicationRoot = .

    # -------------------------------------------------------------------
    #
    # L O G G I N G
    #
    # -------------------------------------------------------------------
    # We use Log4J for all Torque logging and we embed the log4j
    # properties within our application configuration.
    # -------------------------------------------------------------------

    # This first category is required and the category
    # must be named 'default'. This is used for all logging
    # where an explicit category is not specified.

    log4j.category.org.apache.torque = ALL, org.apache.torque
    log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
    #log4j.appender.org.apache.torque.file = d:/work/logs/torque.log
    log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
    log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t] %-5p %c - %m%n
    log4j.appender.org.apache.torque.append = false

    # -------------------------------------------------------------------
    #
    # T O R Q U E P R O P E R T I E S
    #
    # -------------------------------------------------------------------
    # These are your database settings. Look in the
    # org.apache.torque.pool.* packages for more information.
    #
    # The parameters to connect to the default database. You MUST
    # configure these properly.
    # -------------------------------------------------------------------

    torque.database.default=mydb
    torque.database.mydb.adapter=oracle

    # # Using commons-dbcp
    torque.dsfactory.mydb.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
    torque.dsfactory.mydb.pool.maxIdle=8
    torque.dsfactory.mydb.pool.maxActive=10
    torque.dsfactory.mydb.pool.testOnBorrow=true
    torque.dsfactory.mydb.pool.validationQuery=select * from dual
    torque.dsfactory.mydb.connection.driver = oracle.jdbc.driver.OracleDriver
    torque.dsfactory.mydb.connection.url = jdbc:oracle:thin:@192.168.12.186:1521:mydb
    torque.dsfactory.mydb.connection.user = myname
    torque.dsfactory.mydb.connection.password = mypwd

    # Determines if the quantity column of the IDBroker's id_table should
    # be increased automatically if requests for ids reaches a high
    # volume.

    torque.idbroker.clever.quantity=false

    # Determines whether the managers cache instances of the business objects.
    # And also whether the MethodResultCache will really cache results.

    torque.manager.useCache = true


    2、log4j.properties

    # ------------------------------------------------------------------------
    #
    # Logging Configuration
    #
    # $Id: log4j.properties,v 1.10 2005/07/27 04:25:09 huangxq Exp $
    #
    # ------------------------------------------------------------------------


    #
    # If we don't know the logging facility, put it into the
    # ideal.log
    #
    log4j.rootLogger = error, stdout

    #
    # Application debugging
    #
    log4j.category.com.yh = DEBUG, stdout,ideal
    log4j.additivity.com.ideal = false

    #
    # torque goes into torque Log
    #
    log4j.category.org.apache.torque = ERROR, torque
    log4j.additivity.org.apache.torque = false

    ########################################################################
    #
    # Logfile definitions
    #
    ########################################################################

    #print out to console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d [%-5p] [%F] %M : %L -- %m%n

    #
    # root.log
    #
    log4j.appender.root = org.apache.log4j.RollingFileAppender
    log4j.appender.root.MaxFileSize=2000KB
    # Keep one backup file
    log4j.appender.root.MaxBackupIndex=10
    #log4j.appender.root.file = ./logs/root.log
    log4j.appender.root.layout = org.apache.log4j.PatternLayout
    log4j.appender.root.layout.conversionPattern =%d [%-5p] [%F] : %L -- %m%n
    log4j.appender.root.append = false

    #
    # yh.log
    #
    log4j.appender.yh = org.apache.log4j.RollingFileAppender
    log4j.appender.yh.MaxFileSize=2000KB
    # Keep one backup file
    log4j.appender.yh.MaxBackupIndex=10
    log4j.appender.yh.file = ./logs/yh.log
    log4j.appender.yh.layout = org.apache.log4j.PatternLayout
    log4j.appender.yh.layout.conversionPattern =%d [%-5p] [%F] : %L -- %m%n
    log4j.appender.ideal.append = false

    #
    # torque.log
    #
    log4j.appender.torque = org.apache.log4j.RollingFileAppender
    log4j.appender.torque.MaxFileSize=2000KB
    # Keep one backup file
    log4j.appender.torque.MaxBackupIndex=10
    #log4j.appender.torque.file = ./logs/torque.log
    log4j.appender.torque.layout = org.apache.log4j.PatternLayout
    log4j.appender.torque.layout.conversionPattern =%d [%-5p] [%F] : %L -- %m%n
    log4j.appender.torque.append = false


    第三步:初始化torque
    InitServer.java
    Java代碼
    1. package com.yh.core.socket.server;   
    2.   
    3. import java.io.InputStream;   
    4. import java.util.List;   
    5. import java.util.Properties;   
    6.   
    7. import org.apache.commons.configuration.PropertiesConfiguration;   
    8. import org.apache.log4j.Logger;   
    9. import org.apache.log4j.PropertyConfigurator;   
    10.   
    11. import com.yh.util.DBUtils;   
    12. import com.yh.util.FileUtils;   
    13. import com.workingdogs.village.Record;   
    14.   
    15. /**  
    16.  * @author tylzhuang  
    17.  *   
    18.  * TODO To change the template for this generated type comment go to Window -  
    19.  * Preferences - Java - Code Style - Code Templates  
    20.  */  
    21.   
    22. public class InitServer {   
    23.        
    24.     private static Logger log ;   
    25.     private static final String <SPAN class=hilite1><SPAN class=hilite1>TORQUE</SPAN></SPAN>_CONFIG_FILE = "<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>.properties";   
    26.     private static final String LOG4J_CONFIG_FILE = "log4j.properties";   
    27.     public static boolean init() {   
    28.         // 初始化   
    29.         boolean flag = true;   
    30.         ClassLoader cl = InitServer.class.getClassLoader();   
    31.         InputStream logIn = null;   
    32.         InputStream dbIn = null;   
    33.   
    34.         try {   
    35.                
    36.             logIn = cl.getResourceAsStream(LOG4J_CONFIG_FILE);   
    37.             Properties p = new Properties();   
    38.             p.load(logIn);   
    39.             PropertyConfigurator.configure(p);     
    40.             log = Logger.getLogger(InitServer.class);   
    41.             log.debug("InitServer init() log4j init success ---------------" );   
    42.                
    43.                
    44.             //初始化   
    45.             PropertiesConfiguration dbConfig = new PropertiesConfiguration();   
    46.             dbIn = cl.getResourceAsStream(<SPAN class=hilite1><SPAN class=hilite1>TORQUE</SPAN></SPAN>_CONFIG_FILE);   
    47.             dbConfig.load(dbIn);   
    48.             DBUtils.init(dbConfig);   
    49.             log.debug("InitServer init() <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN> init success ---------------" );   
    50.             String testSql = "select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') from dual";   
    51.             String time = null;   
    52.             List list = DBUtils.query(testSql);   
    53.             if(list!=null&&list.size()>0){   
    54.                 Record record = (Record) list.get(0);   
    55.                 time = record.getValue(1).asString();   
    56.                 log.debug("from db init-time: "+time);       
    57.             }   
    58.                
    59.                
    60.         }    
    61.         catch (Exception ex)    
    62.         {   
    63.             log.error("InitServer Exception when init() - "+ex);   
    64.             flag = false;   
    65.         }   
    66.         finally  
    67.         {   
    68.              FileUtils.closeInputStream(logIn);   
    69.              FileUtils.closeInputStream(dbIn);   
    70.         }   
    71.         return flag;   
    72.     }   
    73.   
    74. }  

    DBUtils.java
    Java代碼
    1.   
    2. package com.yh.util;   
    3.   
    4. import java.sql.Connection;   
    5. import java.sql.ResultSet;   
    6. import java.sql.Statement;   
    7. import java.util.List;   
    8.   
    9. import org.apache.commons.configuration.Configuration;   
    10. import org.apache.log4j.Logger;   
    11. import org.apache.<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>.<SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>;   
    12. import org.apache.<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>.util.BasePeer;   
    13.   
    14. /**  
    15.  * @author tylzhuang  
    16.  *   
    17.  * TODO To change the template for this generated type comment go to Window -  
    18.  * Preferences - Java - Code Style - Code Templates  
    19.  */  
    20. public class DBUtils {   
    21.     private static Logger log = Logger.getLogger(DBUtils.class.getName());   
    22.   
    23.     public DBUtils() {   
    24.     }   
    25.   
    26.     public static boolean init(String dbConfigFile) {   
    27.         // 初始化<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>   
    28.         boolean flag = true;   
    29.         try {   
    30.             <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.init(dbConfigFile);   
    31.             System.out.println("---------- 初始化<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>成功---------");   
    32.         } catch (Exception exx) {   
    33.             log.error(exx);   
    34.             flag = false;   
    35.         }   
    36.         return flag;   
    37.     }   
    38.   
    39.     public static boolean init(Configuration dbConfig) {   
    40.         // 初始化<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>   
    41.         boolean flag = true;   
    42.         try {   
    43.             <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.init(dbConfig);   
    44.             System.out.println("---------- 初始化<SPAN class=hilite1><SPAN class=hilite1>torque</SPAN></SPAN>成功---------");   
    45.         } catch (Exception exx) {   
    46.             log.error(exx);   
    47.             flag = false;   
    48.         }   
    49.         return flag;   
    50.     }   
    51.   
    52.     public static Connection getDBConn() {   
    53.         // 取得數(shù)據(jù)庫鏈接   
    54.         Connection conn = null;   
    55.         try {   
    56.             conn = <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.getConnection();   
    57.         } catch (Exception exx) {   
    58.             log.error(exx);   
    59.         }   
    60.         return conn;   
    61.     }   
    62.   
    63.     public static Connection getDBConn(String dbName) {   
    64.         // 取得數(shù)據(jù)庫鏈接   
    65.         Connection conn = null;   
    66.         try {   
    67.             conn = <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.getConnection(dbName);   
    68.         } catch (Exception exx) {   
    69.             log.error(exx);   
    70.         }   
    71.         return conn;   
    72.     }   
    73.   
    74.     public static Connection getDBConn(boolean autoCommitFlag) {   
    75.         // 取得數(shù)據(jù)庫鏈接   
    76.         Connection conn = null;   
    77.         try {   
    78.             conn = <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.getConnection();   
    79.             setAutoCommit(conn , autoCommitFlag);   
    80.         } catch (Exception exx) {   
    81.             log.error(exx);   
    82.         }   
    83.         return conn;   
    84.     }   
    85.   
    86.     public static Connection getDBConn(String dbName, boolean autoCommitFlag) {   
    87.         // 取得數(shù)據(jù)庫鏈接   
    88.         Connection conn = null;   
    89.         try {   
    90.             conn = <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.getConnection(dbName);   
    91.             setAutoCommit(conn , autoCommitFlag);   
    92.         } catch (Exception exx) {   
    93.             log.error(exx);   
    94.         }   
    95.         return conn;   
    96.     }   
    97.   
    98.     public static void closeDBConn(Connection conn) {   
    99.         // 關(guān)閉數(shù)據(jù)庫鏈接   
    100.         try {   
    101.             if (conn != null) {   
    102.                 setAutoCommit(conn , true);// 無論如何,都應(yīng)該在連接關(guān)閉前,將AutoCommit 設(shè)置為   
    103.                 // true   
    104.                 <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.closeConnection(conn);   
    105.                 conn = null;   
    106.             }   
    107.         } catch (Exception exx) {   
    108.             log.error(exx);   
    109.         }   
    110.     }   
    111.   
    112.     public static void closeDBConn(Connection conn, boolean autoCommitFlag) {   
    113.         // 關(guān)閉數(shù)據(jù)庫鏈接   
    114.         try {   
    115.             if (conn != null) {   
    116.                 setAutoCommit(conn , true);// 無論傳什么值,都應(yīng)該在連接關(guān)閉前,將AutoCommit 設(shè)置為   
    117.                 // true   
    118.                 <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.closeConnection(conn);   
    119.                 conn = null;   
    120.             }   
    121.         } catch (Exception exx) {   
    122.             log.error(exx);   
    123.         }   
    124.     }   
    125.   
    126.     public static void closeDBStatement(Statement s) {   
    127.         // 關(guān)閉Statement   
    128.         try {   
    129.             if (s != null) {   
    130.                 s.close();   
    131.                 s = null;   
    132.             }   
    133.         } catch (Exception exx) {   
    134.             log.error(exx);   
    135.         }   
    136.     }   
    137.   
    138.     public static void closeDBObject(Statement s, Connection conn) {   
    139.         // 關(guān)閉Statement   
    140.         try {   
    141.             if (s != null) {   
    142.                 s.close();   
    143.                 s = null;   
    144.             }   
    145.         } catch (Exception exx) {   
    146.             log.error(exx);   
    147.         }   
    148.         // 關(guān)閉數(shù)據(jù)庫鏈接   
    149.         try {   
    150.             if (conn != null) {   
    151.                 setAutoCommit(conn , true);// 無論如何,都應(yīng)該在連接關(guān)閉前,將AutoCommit 設(shè)置為   
    152.                 // true   
    153.                 <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.closeConnection(conn);   
    154.                 conn = null;   
    155.             }   
    156.         } catch (Exception exx) {   
    157.             log.error(exx);   
    158.         }   
    159.     }   
    160.     public static void closeDBResultSet(ResultSet r) {   
    161.         // 關(guān)閉ResultSet   
    162.         try {   
    163.             if (r != null) {   
    164.                 r.close();   
    165.                 r = null;   
    166.             }   
    167.         } catch (Exception exx) {   
    168.             log.error(exx);   
    169.         }          
    170.     }      
    171.     public static void closeDBObject(Statement s, Connection conn,   
    172.             boolean autoCommitFlag) {   
    173.         // 關(guān)閉Statement   
    174.         try {   
    175.             if (s != null) {   
    176.                 s.close();   
    177.                 s = null;   
    178.             }   
    179.         } catch (Exception exx) {   
    180.             log.error(exx);   
    181.         }   
    182.        
    183.         // 關(guān)閉數(shù)據(jù)庫鏈接   
    184.         try {   
    185.             if (conn != null) {   
    186.                 setAutoCommit(conn , true);// 無論傳什么值,都應(yīng)該在連接關(guān)閉前,將AutoCommit 設(shè)置為   
    187.                 // true   
    188.                 <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.closeConnection(conn);   
    189.                 conn = null;   
    190.             }   
    191.         } catch (Exception exx) {   
    192.             log.error(exx);   
    193.         }   
    194.     }   
    195.     public static void closeDBObject(Statement s, ResultSet r ,Connection conn,   
    196.             boolean autoCommitFlag) {   
    197.         // 關(guān)閉Statement   
    198.         try {   
    199.             if (s != null) {   
    200.                 s.close();   
    201.                 s = null;   
    202.             }   
    203.         } catch (Exception exx) {   
    204.             log.error(exx);   
    205.         }   
    206.         // 關(guān)閉ResultSet   
    207.         try {   
    208.             if (r != null) {   
    209.                 r.close();   
    210.                 r = null;   
    211.             }   
    212.         } catch (Exception exx) {   
    213.             log.error(exx);   
    214.         }          
    215.         // 關(guān)閉數(shù)據(jù)庫鏈接   
    216.         try {   
    217.             if (conn != null) {   
    218.                 setAutoCommit(conn , true);// 無論傳什么值,都應(yīng)該在連接關(guān)閉前,將AutoCommit 設(shè)置為   
    219.                 // true   
    220.                 <SPAN class=hilite1><SPAN class=hilite1>Torque</SPAN></SPAN>.closeConnection(conn);   
    221.                 conn = null;   
    222.             }   
    223.         } catch (Exception exx) {   
    224.             log.error(exx);   
    225.         }   
    226.     }   
    227.   
    228.     public static void commit(Connection conn) {   
    229.         try {   
    230.             if (conn != null) {   
    231.                 if (conn.getMetaData().supportsTransactions()   
    232.                     && conn.getAutoCommit() == false)   
    233.                 {   
    234.                     conn.commit();   
    235.                     conn.setAutoCommit(true);   
    236.                 }   
    237.             }   
    238.         } catch (Exception exx) {   
    239.             log.error(exx);   
    240.         }   
    241.     }   
    242.   
    243.     public static void rollback(Connection conn) {   
    244.         try {   
    245.             if (conn != null) {   
    246.                 if (conn.getMetaData().supportsTransactions()   
    247.                     && conn.getAutoCommit() == false)   
    248.                 {   
    249.                     conn.rollback();   
    250.                     conn.setAutoCommit(true);   
    251.                 }   
    252.             }   
    253.         } catch (Exception ee) {   
    254.             log.error(ee);   
    255.         }   
    256.     }   
    257.     public static void setAutoCommit(Connection conn , boolean autoCommitFlag)   
    258.     {   
    259.         try  
    260.         {   
    261.             if (conn.getMetaData().supportsTransactions())   
    262.             {   
    263.                 conn.setAutoCommit(autoCommitFlag);   
    264.             }   
    265.         }   
    266.         catch (Exception e)   
    267.         {   
    268.             log.error(e);   
    269.         }      
    270.     }   
    271.   
    272.     public static List query(String querySql) {   
    273.         List results = null;   
    274.         try {   
    275.             results = BasePeer.executeQuery(querySql);   
    276.         } catch (Exception ee) {   
    277.             results = null;   
    278.             log.error(ee);   
    279.         }   
    280.         return results;   
    281.     }   
    282.     // singleRecord = true 表示只返回一條記錄   
    283.     // singleRecord = false 表示返回所有記錄   
    284.     public static List query(Connection conn, boolean singleRecord,   
    285.             String querySql) {   
    286.         List results = null;   
    287.         try {   
    288.             if (conn != null) {   
    289.                 results = BasePeer.executeQuery(querySql, singleRecord, conn);   
    290.             }   
    291.         } catch (Exception ee) {   
    292.             results = null;   
    293.             log.error(ee);   
    294.         }   
    295.         return results;   
    296.     }   
    297.     // singleRecord = true 表示只返回一條記錄   
    298.     // singleRecord = false 表示返回所有記錄   
    299.     public static List query(Connection conn,   
    300.             String querySql) {   
    301.         List results = null;   
    302.         boolean singleRecord = false;   
    303.         results = query(conn , singleRecord , querySql);   
    304.         return results;   
    305.     }   
    306.   
    307.     //查詢數(shù)據(jù)庫指定配置的數(shù)據(jù)庫   
    308.     public static List query(String dbName ,String querySql) {   
    309.         List results = null;   
    310.         try {   
    311.             Connection conn = DBUtils.getDBConn(dbName);   
    312.             if(conn != null)   
    313.                 results = query(conn , querySql);   
    314.             else  
    315.                 results = null;   
    316.         } catch (Exception ee) {   
    317.             results = null;   
    318.             log.error(ee);   
    319.         }   
    320.         return results;   
    321.     }   
    322.   
    323.     public static int insertOrUpdate(String insertSql) {   
    324.         int results = -1;   
    325.         try {   
    326.             results = BasePeer.executeStatement(insertSql);   
    327.         } catch (Exception ee) {   
    328.             results = -1;              
    329.             log.error(ee);   
    330.         }   
    331.         return results;   
    332.     }   
    333.   
    334.     public static int insertOrUpdate(Connection conn, String insertSql) {   
    335.         int results = -1;   
    336.         try {   
    337.             if (conn != null) {   
    338.                 results = BasePeer.executeStatement(insertSql, conn);   
    339.             }   
    340.         } catch (Exception ee) {   
    341.             results = -1;   
    342.             log.error(ee);   
    343.         }   
    344.         return results;   
    345.     }   
    346.   
    347.        
    348.   
    349. }  
    posted on 2008-05-22 11:33 rogerfan 閱讀(1270) 評論(0)  編輯  收藏 所屬分類: 【Torque學(xué)習(xí)】
    主站蜘蛛池模板: 亚洲成在人天堂在线| 亚洲Av无码国产情品久久 | 亚洲熟妇av一区二区三区漫画| 国产成人精品免费视频大全五级| 大地资源在线观看免费高清| 欧洲精品成人免费视频在线观看 | 成全视频在线观看免费| 国产伦精品一区二区免费| 黄色视频在线免费观看| 在线观看黄片免费入口不卡| 97无码人妻福利免费公开在线视频| 麻豆精品不卡国产免费看| 日本亚洲欧洲免费天堂午夜看片女人员 | 国产亚洲3p无码一区二区| 日韩亚洲一区二区三区| 亚洲日本在线看片| 亚洲女人18毛片水真多| 国产人成亚洲第一网站在线播放| 亚洲AV无码国产剧情| 成人久久久观看免费毛片| 99久久精品毛片免费播放| 99精品视频免费观看| 中文字幕无码免费久久99| 日韩免费高清视频网站| 亚洲免费日韩无码系列 | 爱情岛论坛网亚洲品质自拍| 国产亚洲综合网曝门系列| 亚洲第一视频网站| 亚洲国产精品免费观看 | 看免费毛片天天看| 国产成人无码区免费内射一片色欲| 午夜精品射精入后重之免费观看| 18勿入网站免费永久| 日韩精品成人亚洲专区| 亚洲国产成人一区二区三区| 亚洲国产中文在线二区三区免| 国产精品亚洲一区二区在线观看| 中文字幕手机在线免费看电影| 最近2018中文字幕免费视频| 日本不卡免费新一二三区| 国产AV无码专区亚洲精品|