Export ORACLE data table DDL using JSP

Source: Internet
Author: User
Tags table name
I have been busy sorting out ISO documents over the past few days, and I don't know whether the database manuals I have maintained are complete. I just want to write a program to guide it out ;). The following program expddl. jsp can export the DDL of all data tables of the user currently connected to the database.
EXPDDL. JSP:
<% @ Page contentType = "text/html; charset = gb2312" language = "java" %>
<% @ Page import = "java. SQL. *" %>
<% @ Page import = "oracle. jdbc. OracleDatabaseMetaData" %>
<% @ Page import = "oracle. jdbc. OracleResultSetMetaData" %>
<% @ Page import = "javax. SQL. *, javax. naming. Context" %>
<% @ Page import = "javax. naming. InitialContext" %>
<Div align = "center">
<%
DataSource ds = null;
Context ic = new InitialContext ();
Ds = (DataSource) ic. lookup ("java: comp/env/jdbc/mydb ");
Connection conn = ds. getConnection ();
OracleDatabaseMetaData odmd = (OracleDatabaseMetaData) conn. getMetaData ();
String us = odmd. getUserName ();
String [] types = new String [1];
Types [0] = "TABLE ";
ResultSet rs = odmd. getTables (null, us, "%", types );
While (rs. next ()){
// Obtain the table name
String tname = rs. getString (3 );
%>
<Div align = "center"> table name: <% = tname %> </div>
<Table width = "483" height = "50" border = "1" cellpadding = "2" cellspacing = "0">
<Tr>
<Td> <div align = "center"> No. </div> </td>
<Td> <div align = "center"> ID </div> </td>
<Td> <div align = "center"> type/precision </div> </td>
<Td> <div align = "center"> description </div> </td>
</Tr>
<%
Statement st = conn. createStatement ();
ResultSet rs1 = st.exe cuteQuery ("select * from" + tname );
OracleResultSetMetaData ormd = (OracleResultSetMetaData) rs1.getMetaData ();
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.