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

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

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

    posts - 18,  comments - 1,  trackbacks - 0

    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    public class ConnectionFactory
    {

    /**

    oracle?? 分頁

    select * from (
    select a.*, ROWNUM rn from ( select * from user_info )? a
    where ROWNUM<=40 )
    where rn >=21

    ?


    */
    ??? private static Properties config = new Properties();
    ???
    ??? static
    ??? {
    ??????? try
    ??????? {
    ??????????? InputStream in = ConnectionFactory.class.getClassLoader().getResourceAsStream("dbconfig.properties");
    ??????????? config.load(in);
    ??????????? in.close();
    ??????? }catch(IOException e)
    ??????? {
    ??????????? e.printStackTrace();
    ??????????? throw new ExceptionInInitializerError(e.getMessage());
    ??????? }
    ??? }
    ???
    ??? public static Connection getConnection()
    ??? {
    ??????? if(config.getProperty("jndi-name") != null)
    ??????? {
    ??????????? return getJndiConnection();
    ??????? }
    ???????
    ??????? return getDirectConnection();
    ??? }
    ???
    ??? public static Connection getJndiConnection()
    ??? {
    ??????? Connection con = null;
    ??????? try
    ??????? {
    /**context.xml

    數據源的配置
    <Context>
    ????? <Resource name="jdbc/oracle" auth="Container" type="javax.sql.DataSource" maxActive="2" maxIdle="1" maxWait="-1"
    ????? username="openlab" password="open123" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.0.20:1521:tarena"/>
    </Context?
    */
    ??????????? Context ctx = new InitialContext();
    ??????????? DataSource ds = (DataSource)ctx.lookup("java:comp/env/" + config.getProperty("jndi-name"));
    ??????????? con = ds.getConnection();
    ??????? }catch(Exception e)
    ??????? {
    ??????????? e.printStackTrace();
    ??????? }
    ??????? return con;
    ??? }
    ???
    ??? public static Connection getDirectConnection()
    ??? {
    ??????? Connection con = null;
    ??????? try
    ??????? {
    ??????????? Class.forName(config.getProperty("driver"));
    ??????????? con = DriverManager.getConnection(config.getProperty("dburl") ,config.getProperty("user"), config.getProperty("password"));
    ??????? }catch(ClassNotFoundException cne)
    ??????? {
    ??????????? cne.printStackTrace();
    ??????? }catch(SQLException sqle)
    ??????? {
    ??????????? sqle.printStackTrace();
    ??????? }
    ???????
    ??????? return con;
    ??? }
    ???
    ??? public static void close(ResultSet rs, Statement st, Connection con)
    ??? {
    ??????? try
    ??????? {
    ??????????? rs.close();
    ??????? }catch(Exception e)
    ??????? {
    ??????? }
    ???????
    ??????? try
    ??????? {
    ??????????? st.close();
    ??????? }catch(Exception e)
    ??????? {
    ??????? }
    ???????
    ??????? try
    ??????? {
    ??????????? con.close();
    ??????? }catch(Exception e)
    ??????? {
    ??????? }
    ??? }
    ???
    ??? public static void main(String[] args) throws Exception
    ??? {
    ??????? Connection con = ConnectionFactory.getConnection();
    ??????? System.out.println(con);
    ??????? con.close();
    ??? }
    }

    posted on 2007-04-05 15:30 sunny 閱讀(151) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2007年4月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    293012345

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    相冊

    收藏夾

    朋友

    搜索

    •  

    最新評論

    評論排行榜

    主站蜘蛛池模板: 亚洲av永久无码一区二区三区| 亚洲国产成人私人影院| 成人性生交大片免费看无遮挡 | 一道本不卡免费视频| 91亚洲导航深夜福利| 亚洲人成影院在线观看| 亚色九九九全国免费视频| 成在线人免费无码高潮喷水| 亚洲国产成人久久精品软件| 久久久久久a亚洲欧洲AV| 亚洲中文字幕无码久久2017| 国产精品国产午夜免费福利看 | 国产亚洲成人久久| 精品久久免费视频| 亚洲精品无码av片| 亚洲综合校园春色| 国产又大又黑又粗免费视频| 老司机在线免费视频| 在线永久看片免费的视频| 在线a免费观看最新网站| 中文字幕亚洲免费无线观看日本 | 久久免费观看国产99精品| 亚洲中文字幕久久精品无码APP| 亚洲AV无码乱码在线观看牲色| 免费精品国产自产拍观看| 亚洲伊人成无码综合网 | 中文字幕av无码不卡免费| 日韩免费视频一区二区| 中国人xxxxx69免费视频| 永久免费视频v片www| www.亚洲色图.com| 日韩一级在线播放免费观看| 久久久久亚洲av毛片大| 亚洲福利视频网站| 国产免费A∨在线播放| 很黄很黄的网站免费的| 亚洲综合国产一区二区三区| youjizz亚洲| 免费看少妇高潮成人片| 国产色婷婷精品免费视频| 亚洲伦理一区二区|