Oracle 数据库冷备份及RMAN简单使用
1.jsp调用Oracle
1.安装tomcat
[root@h1 ROOT]# cd /var/App/
[root@h1 App]# unzip apache-tomcat-6.0.14.zip
2.复制ojdbc.jar
[root@h1 ~]# cd /app/oracle/product/11.2.0/dbhome_2/jdbc/lib
[root@h1 lib]# find ojdbc6.jar
ojdbc6.jar
[root@h1 lib]# cp ojdbc6.jar /var/App/apache-tomcat-6.0.14/lib/
[root@h1 lib]# cd /var/App/apache-tomcat-6.0.14/lib/
[root@h1 lib]# ls
annotations-api.jar el-api.jar ojdbc6.jar tomcat-i18n-fr.jar
catalina-ant.jar jasper-el.jar servlet-api.jar tomcat-i18n-ja.jar
catalina-ha.jar jasper.jar tomcat-coyote.jar
catalina.jar jasper-jdt.jar tomcat-dbcp.jar
catalina-tribes.jar jsp-api.jar tomcat-i18n-es.jar
[root@h1 webapps]# cd /var/App/apache-tomcat-6.0.14/webapps/ROOT
[root@h1 ROOT]# vi 1.jsp
<%
<%@page pageEncoding='gbk'%>
<%
out.println("Hello,Everybody");
%>
"1.jsp" [New] 17L, 81C written
3.安装jdk,修改/etc/profile
[root@h1 ROOT]# cd /var/App/
[root@h1 APP]# ./jdk-6u27-linux-x64.bin
[root@h1 App]#vi /etc/profile
export JAVA_HOME=/var/App/jdk1.6.0_27
export PATH=$JAVA_HOME/bin:.:$PATH
export CLASSPATH=$JAVA_HOME/lib:.
"/etc/profile" 84L, 1905C written
[root@h1 App]#source /stc/profile
------------------------
windwos 下修改系统环境变量
用户环境变量添加JAVA_HOME
系统环境变量添加CLASSPATH=%JAVA_HME%\lib
系统环境变量添加PATH=.;%JAVA_HME%\bin;
4.启动tomcat
[root@h1 bin]# cd /var/App/apache-tomcat-6.0.14/bin
[root@h1 bin]# ls
bootstrap.jar catalina-tasks.xml digest.bat service.bat shutdown.bat startup.sh tomcat-juli.jar tool-wrapper.sh
catalina.bat commons-daemon.jar digest.sh setclasspath.bat shutdown.sh tomcat6.exe tomcat-native.tar.gz version.bat
catalina.sh cpappend.bat jsvc.tar.gz setclasspath.sh startup.bat tomcat6w.exe tool-wrapper.bat version.sh
[root@h1 bin]# ./startup.sh
-bash: ./startup.sh: Permission denied
[root@h1 bin]# ./startup.sh
Using CATALINA_BASE: /var/App/apache-tomcat-6.0.14
Using CATALINA_HOME: /var/App/apache-tomcat-6.0.14
Using CATALINA_TMPDIR: /var/App/apache-tomcat-6.0.14/temp
Using JRE_HOME: /var/App/jdk1.6.0_27
5.编写运行
[root@h1 ROOT]# cd /var/App/apache-tomcat-6.0.14/webapps/ROOT
[root@h1 ROOT]# vi
[root@h1 ROOT]# vi db.jsp
<%@ page contentType="text/html;charset=gbk" import="java.sql.*"%>
<%
String url=\'#\'"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url,"u01","abc");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select id ,name from t1");
while(rs.next()){
out.println(rs.getInt(1)+"\t"+rs.getString(2)+"<br>");
}
%>
~
"db.jsp" 12L, 432C written
[root@h1 ROOT]#