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

    隨筆分類

    隨筆檔案

    相冊

    收藏夾

    朋友

    搜索

    •  

    最新評論

    評論排行榜

    主站蜘蛛池模板: 国产一区二区三区免费视频| 精品无码免费专区毛片| 国产成人免费A在线视频| 亚洲欧洲精品在线| 97在线视频免费公开观看| 久久精品亚洲一区二区| 91在线免费视频| 国产亚洲精品美女久久久| 两性色午夜免费视频| 亚洲自偷自偷图片| 中出五十路免费视频| 久久久亚洲精品国产| 无码囯产精品一区二区免费| 亚洲国产综合91精品麻豆| 日韩午夜理论免费TV影院| 久久精品国产亚洲77777| 免费福利网站在线观看| 中文字幕亚洲情99在线| 国产精品深夜福利免费观看| 免费人成再在线观看网站| 亚洲伊人久久综合影院| 日本一道本不卡免费| 亚洲美女大bbbbbbbbb| 成人无码区免费A片视频WWW | 久久国产亚洲精品麻豆| 无码一区二区三区免费| 亚洲成人激情小说| 亚洲高清无码综合性爱视频| 久久99免费视频| 亚洲一卡二卡三卡| 波多野结衣一区二区免费视频 | 91在线免费观看| 亚洲国产成人超福利久久精品| 日本免费福利视频| 国产麻豆一精品一AV一免费| 亚洲精品国产福利片| 亚洲v国产v天堂a无码久久| 国产白丝无码免费视频| 亚洲精品无码不卡在线播放| 中文国产成人精品久久亚洲精品AⅤ无码精品| 国产激情免费视频在线观看|