<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)

    隨筆分類

    隨筆檔案

    相冊

    收藏夾

    朋友

    搜索

    •  

    最新評論

    評論排行榜

    主站蜘蛛池模板: 和日本免费不卡在线v| 中文字幕成人免费高清在线视频| 永久免费视频网站在线观看| 国产亚洲精品一品区99热| 中文字幕无码一区二区免费| 在线观看亚洲精品国产| 中文字幕一区二区免费| 亚洲熟女少妇一区二区| 在线观看片免费人成视频无码| 亚洲人成人77777网站| 免费人成黄页在线观看日本| 亚洲av丰满熟妇在线播放| 日本免费大黄在线观看| 亚洲天堂电影在线观看| 免费观看美女裸体网站| 精品韩国亚洲av无码不卡区| 亚洲成a人一区二区三区| 国产免费高清69式视频在线观看| 久久国产亚洲电影天堂| 在线永久看片免费的视频| 久久久久亚洲AV无码去区首 | 69堂人成无码免费视频果冻传媒 | jizz免费在线影视观看网站| 亚洲中文字幕无码久久精品1 | 2019中文字幕在线电影免费 | 国产精品免费电影| 国产精品免费久久久久电影网| 亚洲AV无码一区东京热久久| 1区2区3区产品乱码免费| 亚洲av中文无码乱人伦在线观看 | 久久精品人成免费| 亚洲а∨精品天堂在线| 91麻豆精品国产自产在线观看亚洲| 一区二区三区福利视频免费观看| 亚洲自国产拍揄拍| 亚洲第一页综合图片自拍| 免费看搞黄视频网站| 亚洲A∨精品一区二区三区下载| 久久亚洲AV无码西西人体| 国产福利视精品永久免费| 日韩大片在线永久免费观看网站|