Traditional JAVA connection to oracle databases

Source: Internet
Author: User

If you use the traditional method to connect to the oracle database, you can use JAVA scripts in the oracle database. The following describes how to connect to the oracle database using the traditional method.

This method connects JAVA to the oracle database. Its performance, reliability, and stability gradually decrease with the increase of user traffic. The tracking test shows that the root problem is related to the creation of the Connection object. But here we will talk about the implementation of this method: Add records to database tables.

 
 
  1. Import java. SQL. Connection;
  2. Import java. SQL. DriverManager;
  3. Import java. SQL. PreparedStatement;
  4.  
  5. String driver = "oracle. jdbc. driver. OracleDriver ";
  6. String url = "jdbc: oracle: thin: @ 192.168.1.3: 1521: ora92 ";
  7. String username = "scott ";
  8. String password = "tiger ";
  9. String SQL = "insert into users (username, password) values (?,?) ";
  10.  
  11. Try {
  12.  
  13. Class. forName (driver); // oracle. jdbc. driver. OracleDriver ();
  14. Connection conn = DriverManager. getConnection (url, username, password );
  15. PreparedStatement ps = conn. prepareStatement (SQL); // Statement stat = conn. createStatement ();
  16.  
  17. Ps. setString (1, "Zhang San ");
  18. Ps. setString (2, "lisi ");
  19. Ps.exe cuteUpdate ();
  20. Ps. close ();
  21. Conn. close ();
  22.  
  23. } Catch (ClassNotFoundException e ){
  24. E. printStackTrace ();
  25. } Catch (SQLException e ){
  26. E. printStackTrace ();
  27. }

Oracle backup command to use instances

Introduction to Oracle bitand () Functions

Use of oracle Aggregate functions

Oracle functions for Calculating Time Difference

Use of oracle custom functions

Related Article

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.