新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
使用組件實(shí)現(xiàn)JAVA連接Oracle數(shù)據(jù)庫
下面介紹JAVA連接Oracle數(shù)據(jù)庫的方法主要以Commons DbUtils組件來連接數(shù)據(jù)庫。該JAVA連接Oracle數(shù)據(jù)庫得方法供您參考,希望對您能有所幫助。

它將JDBC中的一些類進(jìn)行了二次封裝,它不象hibernate(ORMapping)那樣將JAVA對象與數(shù)據(jù)庫映射。首先將oracle驅(qū)動(dòng)類文件與Commons DbUtils組件的JAR文件一起引入到項(xiàng)目中。
- String sql = "insert into users(username,password) values(?,?)";
- String username = request.getParameter("username");
- String param[]={StringUtil.filterHtml(username),StringUtil.filterHtml(request.getParameter("password"))
- };
- try {
- Context initContext = new InitialContext();
- DataSource ds = (DataSource) initContext.lookup("java:/comp/env/jdbc/oracleds");
- QueryRunner qr = new QueryRunner(ds);
- result = qr.update(sql, param);
- } catch (NamingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
網(wǎng)站欄目:使用組件實(shí)現(xiàn)JAVA連接Oracle數(shù)據(jù)庫
網(wǎng)站地址:http://www.5511xx.com/article/dhodpji.html


咨詢
建站咨詢
