Linux上部署XSQL 的Web应用

第一步: 配置JDK 1.5.X

第二步: 配置Tomcat6.0.X

第三步: 安装配置ORACLE10G

创建用户“MOMNPUP”: create user MOMNPUP identified by MOMNPUP;
                      grant create session,resource to MOMNPUP:
构造数据:
create table  EMPLOYEE (
id NUMBER,
lastname varchar2(15),
firstname varchar2(15),
job varchar2(30)
);
insert into EMPLOYEE (id,lastname,firstname,job) values(1,'N''Pop','John','Catalog Editor');
insert into EMPLOYEE (id,lastname,firstname,job)
values(2,'N''Pop','Mom','Boss');

第四步: 配置XSQL的WEB应用所需的jar包

       jlib/sax2.jar
       rdbms/jlib/xsu12.jar
       lib/xmlparserv2.jar
       lib/oraclexsql.jar
       jdbc/lib/classes12.jar
       xdk/admin

列一下oracle用户的.bash_profile内容

# .bash_profile

ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
ORACLE_SID=ora9

#XSQL
#TOMCAT
CATALINA_HOME=/home/oracle/tomcat/apache-tomcat-6.0.18


#JDK
JAVA_HOME=/home/oracle/jdk/jdk1.5.0_10
CLASSPATH=/home/oracle/jdk/jdk1.5.0_10/lib:
/u01/app/oracle/oracle/product/10.2.0/db_1/jlib:
/u01/app/oracle/oracle/product/10.2.0/db_1/rdbms/jlib:
/u01/app/oracle/oracle/product/10.2.0/db_1/lib/xmlparserv2.jar:
/u01/app/oracle/oracle/product/10.2.0/db_1/lib/oraclexsql.jar:
/u01/app/oracle/oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar:
/u01/app/oracle/oracle/product/10.2.0/db_1/xdk/admin:
/home/oracle/tomcat/apache-tomcat-6.0.18/lib:
/u01/app/oracle/oracle/product/10.2.0/db_1/oc4j/rdbms/jlib/xsu12.jar

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$JAVA_HOME/bin:/home/oracle/tomcat/apache-tomcat-6.0.18/bin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export CATALINA_HOME JAVA_HOME CLASSPATH  ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH 
#export DISPLAY= 192.168.203.133:0.0
unset USERNAME



第五步: 构建Web工程XSQL

       rdbms/jlib/xsu12.jar
       lib/xmlparserv2.jar
       lib/oraclexsql.jar
       jdbc/lib/classes12.jar
       将上面的jar包拷贝到Tomcat下面的lib中。

      webapp/XSQL/
                  WEB-INF/ classes/XSQLConfig.xml
                  WEB-INF/  web.xml                            
                  text.xsql

web.xml文件内容:

<?xml version = '1.0' encoding = 'GB18030'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
    <description>Empty web.xml file for Web Application</description>
    <servlet>
        <servlet-name>XSQL</servlet-name>
        <servlet-class>oracle.xml.xsql.XSQLServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>XSQL</servlet-name>
        <url-pattern>*.xsql</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>35</session-timeout>
    </session-config>
    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
</web-app>




XSQLConfig.xml 文件内容:

<connectiondefs>   

<connection name="MOMNPUP">
          <username>MOMNPUP</username>
          <password>MOMNPUP</password>
          <dburl>jdbc:oracle:thin:@localhost:1521:ora9</dburl>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <autocommit>false</autocommit>
</connection>
   
  </connectiondefs>


text.xsql文件内容:

<?xml version="1.0" encoding='UTF-8'?>
<page xmlns:xsql="urn:oracle-xsql" connection="MOMNPUP" >
<xsql:query >
    select * from Employee
</xsql:query>
</page>


第六不访问WEB应用:


http://localhost:8080/XSQL/test.xsql

返回结果页面显示:

<page>
<ROWSET>
   <ROW num="1">
     <ID>1</ID>
     <LASTNAME>N'Pop</LASTNAME>
     <FIRSTNAME>John</FIRSTNAME>
     <JOB>Catalog Editor</JOB>
   </ROW>

<ROW num="2">
    <ID>2</ID>
    <LASTNAME>N'Pop</LASTNAME>
    <FIRSTNAME>Mom</FIRSTNAME>
    <JOB>Boss</JOB>
</ROW>
</ROWSET>
</page>




























                 

      

    

你可能感兴趣的:(oracle,tomcat,Web,linux,jdbc)