JAVA can be used to connect to the Oracle database through the JDBC data source connection pool. This method is described in detail below. If you are interested in connecting to the Oracle database using JAVA, take a look.
- High database connection efficiency using JDBC data source connection pool)
-
- Before connecting to the database in this way, you must first configure the file \ tomcat5 \ conf \ context. xml in the TOMCAT server directory:
-
- <Context reloadable = "true">
-
- <WatchedResource> WEB-INF/web. xml </WatchedResource>
-
- <Resource name = "jdbc/oracle" auth = "Container" type = "javax. SQL. DataSource"
- MaxActive = "100" maxIdle = "30" maxWait = "10000" username = "scott" password = "tiger"
-
- DriverClassName = "oracle. jdbc. OracleDriver"
- Url = "jdbc: oracle: thin: @ 192.168.1.3: 1521: ora92"/>
-
- </Context>
-
- After configuration, copy the oracle Driver Class classes12.jar to the \ tomcat5 \ common \ lib directory. I have encountered this problem and finally solved it. Previously, when I used the ojdbc5.jar driver class file, I was always unable to establish a connection, and the following problem occurs: Cannot create JDBC oracle driver of class ''for connect url' jdbc: oracle: thin: @ 192.168.1.3: 1521: ora92 '". I hope this article will give readers some inspiration. My QQ number: 89262840
-
- Import javax. naming. Context;
- Import javax. naming. InitialContext;
-
- Import javax. SQL. DataSource;
-
- String SQL = "insert into users (username, password) values (?,?) ";
-
- String username = request. getParameter ("username ");
-
- Try {
-
- Context context = new InitialContext ();
- DataSource ds = (DataSource) context. lookup ("java:/comp/env/jdbc/oracle ");
- Connection conn = ds. getConnection ();
-
- PreparedStatement ps = conn. prepareStatement (SQL );
-
- Ps. setString (1, StringUtil. filterHtml (username ));
- Ps. setString (2, StringUtil. filterHtml (request. getParameter ("password ")));
- Result = ps.exe cuteUpdate ();
- Ps. close ();
- Conn. close ();
-
- } Catch (NamingException e ){
- E. printStackTrace ();
- } Catch (SQLException e ){
- E. printStackTrace ();
- }
-
The preceding section describes how to connect to an Oracle database using the JDBC data source connection pool.
C # connect to the Oracle database to query data
Connect to the Oracle database through the OCI8 Interface
Instances that use oracle Stored Procedure Paging
Oracle RMAN backup Optimization
Oracle backup using RMAN