Oracle与Tomcat服务器连接方法
折腾了一晚上加一上午终于把Oracle 10g数据库与Tomcat服务器连接上了,用了很长时间,其实也挺简单的。我用的是Java做的,有两种
折腾了一晚上加一上午终于把Oracle 10g数据库与Tomcat服务器连接上了,用了很长时间,其实也挺简单的。
我用的是Java做的,有两种方法。
相关阅读:Oracle 下spfile和pfile使用笔记
(一)//装载驱动
//首先在控制面板中,找到管理工具,然后在里面打开ODBC源,在里面新建一个oracle的数据源,OK即
//可,这不还很容易。
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//连接
Connection ct = DriverManager.getConnection("jdbc:odbc:myorcl","user","psw");//红色的分别为
//ODBC数据源,oracle里面的账户,相应的密码
Statement sm = ct.createStatement();
ResultSet rs = sm.executeQuery("select * from emp");//这句就是例子了
注:此方法只适用于服务器与数据库在同一台电脑上的情况,我在用MyEclipse启动tomcat时可以正常运行,但是部署到tomcat上后,单独启动tomcat,就不能运行了,这个不解,所以我又试了第二种方法。
(二)//装载驱动
//首先点到你的工程,属性->ADD EXTRA JARS,在到oracle下搜索classes12.jar,并加载进去,具体路
//径忘了
Class.forName("oracle.jdbc.driver.OracleDriver");
//连接
Connection ct = DriverManager.getConnection("jdbc:oracle:thin:@IP:1521:myorcl");//IP为你本机
//IP,,因为用localhost和127.0.0.1测试均不好用;myorcl为你的数据库实例
//下面和第一种方法一样了,就不写了
//第二种方法还有个有点就是,服务器和数据库可以不在同一台机子上
哎,其实很容易,让我折腾了一天的时间。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

This article introduces how to troubleshoot memory leaks through Tomcat logs and related tools. 1. Memory monitoring and heap dump First, use tools such as JVisualVM or jstat to monitor Tomcat's memory usage in real time, observe the changes in the heap memory, and determine whether there is a memory leak. Once a leak is suspected, use the jmap command to generate a heap dump file (heap.bin): jmap-dump:format=b,file=heap.bin, which is the Tomcat process ID. 2. Heap dump file analysis Use EclipseMemoryAnalyzerTool (MAT) or other tools to open the heap.bin file and analyze the memory.

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.
