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.
- Import java. SQL. Connection;
- Import java. SQL. DriverManager;
- Import java. SQL. PreparedStatement;
-
- String driver = "oracle. jdbc. driver. OracleDriver ";
- String url = "jdbc: oracle: thin: @ 192.168.1.3: 1521: ora92 ";
- String username = "scott ";
- String password = "tiger ";
- String SQL = "insert into users (username, password) values (?,?) ";
-
- Try {
-
- Class. forName (driver); // oracle. jdbc. driver. OracleDriver ();
- Connection conn = DriverManager. getConnection (url, username, password );
- PreparedStatement ps = conn. prepareStatement (SQL); // Statement stat = conn. createStatement ();
-
- Ps. setString (1, "Zhang San ");
- Ps. setString (2, "lisi ");
- Ps.exe cuteUpdate ();
- Ps. close ();
- Conn. close ();
-
- } Catch (ClassNotFoundException e ){
- E. printStackTrace ();
- } Catch (SQLException e ){
- E. printStackTrace ();
- }
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