<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

    數(shù)據(jù)源的配置
    <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) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    <2007年4月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    293012345

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    相冊(cè)

    收藏夾

    朋友

    搜索

    •  

    最新評(píng)論

    評(píng)論排行榜

    主站蜘蛛池模板: 国产精品亚洲一区二区三区| 亚洲高清中文字幕| 美女裸免费观看网站| 无人影院手机版在线观看免费| 亚洲av中文无码乱人伦在线播放 | 四虎永久在线精品免费网址| 亚洲偷自精品三十六区| 久久久久久久91精品免费观看| 亚洲大片免费观看| 毛片a级毛片免费观看免下载| 日韩亚洲国产综合高清| 久久久影院亚洲精品| A级毛片高清免费视频在线播放| 亚洲AV无码专区国产乱码4SE| 无码成A毛片免费| 亚洲熟妇无码久久精品| 欧洲精品成人免费视频在线观看| 亚洲精品无码少妇30P| 亚洲AV伊人久久青青草原| 久久九九免费高清视频| 青青草原精品国产亚洲av| 99视频全部免费精品全部四虎| 亚洲人成77777在线观看网| 国产精品无码一区二区三区免费| 婷婷亚洲综合一区二区| 亚洲精品乱码久久久久久自慰 | 日韩精品成人无码专区免费| 无码天堂va亚洲va在线va| 国产亚洲美女精品久久久2020 | www亚洲精品久久久乳| 亚洲精品国产精品乱码不卞| 国产午夜不卡AV免费| 国产人成亚洲第一网站在线播放| 婷婷亚洲天堂影院| 久久99热精品免费观看牛牛| 亚洲人成网亚洲欧洲无码| 中文字幕亚洲电影| 特级毛片免费观看视频| 亚洲AV综合色一区二区三区| 夭天干天天做天天免费看| 国产成年无码久久久免费|