Use components to connect to Oracle databases in JAVA

Source: Internet
Author: User

The following describes how to connect JAVA to the Oracle database by using the Commons DbUtils component to connect to the database. You can use this JAVA method to connect to the Oracle database for your reference.

It encapsulates some classes in JDBC twice, and maps JAVA objects to databases like hibernateORMapping. First, introduce the oracle Driver Class file and the JAR file of the Commons DbUtils component to the project.

 
 
  1. String sql = "insert into users(username,password) values(?,?)";  
  2.  
  3. String username = request.getParameter("username");  
  4.  
  5.     String param[]={StringUtil.filterHtml(username),StringUtil.filterHtml(request.getParameter("password"))  
  6.     };  
  7.  
  8. try {  
  9.  
  10.     Context initContext = new InitialContext();  
  11. DataSource ds = (DataSource) initContext.lookup("java:/comp/env/jdbc/oracleds");  
  12. QueryRunner qr = new QueryRunner(ds);  
  13. result = qr.update(sql, param);  
  14.  
  15.    } catch (NamingException e) {  
  16.  // TODO Auto-generated catch block  
  17.  e.printStackTrace();  
  18. } catch (SQLException e) {  
  19.    e.printStackTrace();  
  20.     }  

C # connect to the Oracle database to query data

Test connection to the Oracle Database Server

Connect Perl to the Oracle database

Connect to the Oracle database through the OCI8 Interface

Three methods for automatic Oracle Database Backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.