<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 閱讀(154) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 女人张腿给男人桶视频免费版| 中文字幕专区在线亚洲| 亚洲免费观看在线视频| 久久ww精品w免费人成| 日韩精品极品视频在线观看免费 | 亚洲国产成人a精品不卡在线| 日韩精品无码人妻免费视频| 成人看的午夜免费毛片| 全免费一级午夜毛片| 国产精品成人免费综合| 免费看国产曰批40分钟| 亚洲国产午夜福利在线播放| 亚洲区小说区图片区| 亚洲精品无码久久久久sm| 亚洲AV无码成人精品区天堂| 亚洲天堂中文资源| 亚洲综合综合在线| 99999久久久久久亚洲| 亚洲国产AV无码一区二区三区 | 亚洲天堂一区二区三区| 亚洲三级视频在线观看 | 亚洲七七久久精品中文国产| 亚洲无线码在线一区观看| 亚洲成在人天堂在线| 亚洲a级片在线观看| 国产精品亚洲二区在线| 精品国产污污免费网站入口在线| 成人性生交大片免费看中文| 免费观看国产网址你懂的| 日韩高清免费在线观看| 国产成人亚洲综合| 亚洲日本一区二区| 亚洲精品人成网线在线播放va | 亚洲国产成人综合| 亚洲AV无码一区二区三区久久精品| 特级av毛片免费观看| 黄网站免费在线观看| 无码人妻一区二区三区免费| www亚洲精品少妇裸乳一区二区| 国产精品亚洲A∨天堂不卡| 亚洲国产精品yw在线观看|