JSP and SQL Queries

Hello,
If a JSP application needs Database connectivity to display some values, what is the best approch for the same.
1. Using SQL connections with resultset
2. Using Java Class and using the same in JSP.
3. any other??
what is the industry standard for the same.
Thnx,,
Girish

JSP's are used to display a view (such as a user interface or a report). Database connectivity is business logic and you don't do business logic in JSP's. I would create a servlet to handle business logic and then put the database logic in seperate classes that you can call from the servlet. Then use a JSP with JSTL to display the results of the database query. Putting the business logic in seperate classes makes it reusable.
Frameworks such as Struts, Spring, JSF, etc. work in similar ways, so I guess you can call it an "industry standard". In software development there is no such thing however, you develop to solve a problem, not to follow standards.
If you want to do it this way I suggest you lookup these two things:
1) how to make servlets and JSP's work together
2) the Model View Controller pattern

Similar Messages

  • PLSQL Blocks and SQL Queries in APEX

    Hello,
    Is it possible at all to view undelrying Oracle PLSQL and SQL queries in a run time APEX 3.2 application?
    More elaboratively, can a smart APEX Site user or visitor find a way to see underlying SQL queries and PLSQL code objects?
    Thanks,
    R

    Hi,
    If you just want to see what sql is executed by a session you can use sql trace. This can be switched on for a whole system but is usually more usable when switched on for individual users. The problem with a system like APEX is that database sessions are not directly associated with APEX users and APEX sessions can share database sessions.
    I haven't tried it, but one method that may work is to put a schema logon trigger on the APEX_PUBLIC_USER which switches on tracing when ever this user logs on to the database. It may take a little detective work to understand the sequence of things but all the SQL executed by this user will be recorded and can be analyzed for performance etc. The command to enable SQL tracing could be embedded in the APEX app, but it may be a little random as to which db session has it enabled.
    Perhaps a better tracing option could be seen as a feature request in a future version of APEX.
    Regards
    Andre

  • How exit for a script having set of pl/sql blocks and sql queries

    HI,
    I have set of blocks and sql queries in a script.
    In some cases I want to stop the excution of next statements and blocks.
    As in pl/sql block We can use return , in case of loop we can use exit, so what is to be use in case if sql script which contain set of blocks and sql queries.
    Thanks and Regards in Advance,

    Hi,
    how to exit from the script if confirm_to_continue is set to 'N'.
    i.e in this case I want the preceding statements not to be excuted.
    Please suggest.
    script:
    declare /*BLOCK NO1*/
    begin
    IF &&confirm_to_continue = 'N'
    THEN
    ---exit from from whole script
    RETURN; -- this will only exit from this block
    END IF;
    end;
    host IF EXIST &file_name (del &file_name) ELSE (echo missing)
    declare /*BLOCK NO 2*/
    begin
    end;
    /

  • Business Logic - Success of Tag and SQL Queries

    Greetings All,
    I have a Logic flow from an old NQL process. 
    The process Gets some SQL and Tag Data then checks to see if data was returned and notifies via email if data wasn't returned.  So this would translate into the Tag and SQL Queries followed by a Logic Conditional block.
    HERE's the questions:
    In BLS, if the SQL and/or Tag Query fail, the entire process quits (at least when Executed locally) and never gets to the Logic Conditional block to verify the tagQuery.success or SQLQuery.success.
    Is this what it does when run as a scheduled task also???
    Is there any onError then do... type of parameter???
    Any Suggestions would be appreciated...
    Thanks
    Dennis West

    Dennis, it shouldn't "quit".  The Success property should be set to false, and the error caught (typically).  Sounds like a bug.

  • Authorisation Groups and SQL Queries

    I want to give some employees access to certain SQL queries in SAP1.
    I've created a Category Name and have ticked the Authorisation Group 1. Within this Category I've saved my queries that I want users to access.
    I've then gone to Authorisations, General Authorisations, Selected the Employee, then Reports, Query Generator, and then allowed full authorisation to Saved Queries Group No. 1 and Read Only rights to Query Manager.
    When user goes to Tools Queries, and selects Category name and any SQL query therein, cannot open.
    I've tried allowing them full authorisation to Query Manager but this gives users access to ALL queries.
    Any thoughts anyone?
    D

    Where is your Query Manager Authorisation ? I could only find Query Generator.  If the same apply to you, then you don't need to assign any right to this category but only the selected group to full. Query Generator Authorisation will automatically become Various Authorisation.
    Thanks,
    Gordon

  • JSP and SQL

    Dear friends,
    plz do help for the problem.
    I have a large SQL query(with a subquery into it) to Oracle database, using which I want to generate a report. The SQL query is quite large taking into consideration all the various parameters needed to generate the report.The SQL is tested perfectly on SQL Plus prompt and gives me the desired result .I want to make a JSP application out of it and give it to all users, so that they can change the parameters and get the desired report. The report contains some 10,000 records. I want to build the application for intranet usage. I am using all Javabeans to do most of the work and JSP page just uses these javabeans. Now I am in doubt weather such a long queryString can at all be executed using a thin client connection to database.
    And if it executes, what will be the perfomance issues for such an application.
    I have a separate web server running Tomcat 4.2.29, separate Oracle 8.0 on Windows NT, and a separate Windows NT domain server to validate the users. I have a separte java application running on these servers using visibroker 3, Oracle 8.
    Kindly help me with a suggestion or some coding or any architectural proposal to make such an application.
    sukrudra

    thanks for reply.
    There are certain things that i want to clear, i am handling all the plumbing type of work like closing the connections etc thru my code.Even my CPU speed is fairly good enough. but i am very worried about the nested subsqueries that i will be running thru the program.
    It is here my performance and result come sinto question. My client get most of the records but some the records are getting lost towards the end.It is at this end that i cannot figure out what the problem might be.
    Also do let me know your email.

  • Jsp and sql - very slow performance

    Hello,
    I am new to java and working on my site.
    I encountered very low performance when I have implemented this function.
    This functions counts responses for each ad.
    Could you share know-how about better implementation?
    in index.jsp I have this call:
    out.println("<td align=\"center\">" + getRecords.countOffers(A.getIdads()) + "</td>");
    this is getRecords.countOffers:
    public static int countOffers(int ID) {
    int offersqty = 0;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con = (Connection) DriverManager.getConnection(DBurl, user, password);
    Statement stmnt = (Statement) con.createStatement();
    String readTopic = "SELECT idoffers FROM `wishloft`.`offers` where idads='" + ID + "';";
    ResultSet displayTopic = stmnt.executeQuery(readTopic);
    while (displayTopic.next()) {
    offersqty++;
    displayTopic.close();
    con.close();
    } catch (Exception e) {
    return offersqty;
    }

    Well, for starters, when posting additional code, please use tags.
    As for "looking" correct, I would offer these suggestions:
    - Use a PreparedStatement instead of just a String to build your query (as I suggested earlier)
    - Since you are expecting only 1 record from your query, why use a while() loop?  If someone else has to come in and look at your code, it could lead to confusion.  Just get the first record and process it without any loops.
    Also, only you can tell us if it performs correctly, because you should know what the results are since it's your data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • JSP and SQL.. not displaying records

    <html>
    <body>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <P> The results are: </P>
    <%-- connection to database--%>
    <%
    Connection con=null;
    Statement stmt = null;
    ResultSet rs = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con=DriverManager.getConnection("jdbc:odbc:dbex","admin","admin");
    stmt=con.createStatement();
    String queryText = "select first_name,last_name from dbex";
    rs = stmt.executeQuery(queryText);
    while (rs.next())
    out.print(rs.getString("first_name"));
    out.print("\t");
    out.print(rs.getString("last_name"));
    } catch (SQLException e)
    %>
    <% try {
    if(rs != null)
    rs.close();
    rs = null;
    if(stmt != null)
    stmt.close();
    stmt = null;
    if(con != null)
    con.close();
    con = null;
    } catch (SQLException e) {} %>
    </body>
    </html>
    this is the code. but nothing is displayed other than the html code.. why is it so.I have two fields in the database . one first_name and second last_name.can anybody help me?

    try replacing this:
    while (rs.next())
    out.print(rs.getString("first_name"));
    out.print("\t");
    out.print(rs.getString("last_name"));
    with this:
    while (rs.next())
    out.println(first_name);
    out.println("\t");
    out.println(last_name);

  • Indexes and SQL queries

    I want to know if the index would be used with this query.
    >
    I have a table with 4 columns -- columns A,B,C, and D.
    I have a unique index on columns A,B,and C.
    If my SQL statement includes only columns A and B in the where clause, would this index be used?
    The user arrived at from
    The user appears to be using Microsoft Internet Explorer 4.0 (compatible; MSIE 4.01; Windows NT)null

    Yes the index is used.
    It's important that your clause contains column A (the firsto of the index)

  • Jsp and sql and dates!

    Hi
    When I try to run this statement I get the following error:
    ORA-01861: literal does not match format string
    "insert into ps_cs_stock_grants_hist values('90980','2002-01-07 00:00:00.0','ONGO','2002-01-07 00:00:00.0','1250','0','USD','96','NQ','2002-01-07 00:00:00.0','N','N','N','622745', '2002-04-17 00:00:00.0','1250','5','BEL_5C_DX ',' ','0','C', '2002 Ongoing Stock PartI ', '2002-04-17 00:00:00.0')"
    I know my problem is with dates as it works when I replace 2002-01-07 with 07-JUL-2002. Question is how? This is the code that creates the above:
    int i = myStmt.executeUpdate("insert into ps_cs_stock_grants_hist values('" + vEmplid + "','" + vGrantdate + "','" + vOptionreason + "','" + vBoarddt + "','" + vOriginalopt + "','" + vOrigacqpc + "','" + vCurrencycd + "','" + vOptionplan + "','" + vOptiontype + "','" + vSpliteligdt + "','" + vRefusegrant + "','" + vStockoptplan + "','" + vCommitment + "','" + vGrantno + "', '" + vRegisterdate + "','" + vRegistershares + "','" + vStockvesting + "','" + vVestingtemplat + "','" + vVpemplid + "','" + vVestcredit + "','" + vGrantstatus + "', '" + vComments + "', sysdate)");

    Are you asking how to convert your existing date to the MySQL format?
    What data type are you using for your dates? Here's a quick-and-dirty way, assuming you're using Date for your dates:String convertDate(Date date){
    GregorianCalendar calendar = new GregorianCalendar();
          String dateStr = new String();
          String months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"};
          calendar.setTime(date);
          dateStr = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)) + "-";
          dateStr += months[calendar.get(Calendar.MONTH)] + "-";
          dateStr += Integer.toString(calendar.get(Calendar.YEAR));
          return dateStr;
    }

  • SQL Queries in Code V/s Stored Procedures

    Hi Friend,
    Can any one of you guide me with following..
    What is faster ? using SQL Queries in Java code or using Stored Procedures which are called from code?
    I understnd Stroed Procedures are faster and definitely it provides more maintainability.
    If any one can give me any links or resources which outlines pros and cons of using Stored Proc and SQL Queries embedded in Java than it would be a great help..
    If there are any articles which proves either of the above is a preferred way, that would also help..
    Appreciate the effort in advance !!
    Thanks
    Gurudatt

    Well one benefit of Stored Procs is that you "compile" it on the database whereas you might build your query on the fly in java... test coverage is important in order not to have such things as a typo in a column name....
    Still, if you change a table, you have to go through all the procedures in SQL and likely to do so in some of your business object... and trust me, that can be hell!
    It all depends on the use of the app...
    From my experience, Stored procedure are much faster than built-on-the-fly SQL (and quite faster than prepared statements depending on the JDBC driver, the re-use of connections etc...)....
    IMHO, you'd probably be wise to start of with prepared statements, and when the schema seems stable enough (ie unlikely to change), look for the slower queries and convert them to stroed procedures.
    If you don't have to support several databases and are tight on performance, you can even include some logic in your stored procedure (e.g. update several tables, based on various selects...etc...). The language is usually quite powerful, and that can save you the run-time of selecting, converting to object , process and update (i.e. several roud-trip between DB and app)...
    Tshcuss!
    Chris

  • SQL queries in JSP

    Does anyone know how to create a JSP which allows the user to input data into a simple database and then allow the user to input SQL queries? I can do this in a servlet but must hard code the query. It would be great to be able to type in differnet queries to see the results.
    Thanks
    Michael

    hai,
    I am giving u a small example which allows user to enter data in the html page and the same is submitted by the Jsp page in the database.
    <%@ page language="java" import="java.sql.*" %>
    <html>
    <body bgcolor="#FFd08d" >
    <%!     Connection conn;
         Statement st,st1;
         ResultSet rs,rs1;
         int i,j;
    %>
    <%     
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn=DriverManager.getConnection("jdbc:odbc:--DSNName--","--DataBaseUserName--","--DataBasePassword--");
         catch(Exception e)
    %>
         Error in Saving : <%=e%>
    <%
         try
         String email_address=request.getParameter("email_address");
         String query_text=request.getParameter("query_text");     
         PreparedStatement st=null;
         String inst="insert into databasename..DataBaseTableName(email_address,query_text) values (?,?)";
         st=conn.prepareStatement(inst);
         st.setString(1,email_address);
         st.setString(2,query_text);
         st.executeUpdate();
         conn.close();
    %>
    Your query is Submitted.<br>
    Thanks.
    <%
         catch(SQLException e)
    %>
    Error in Saving : <%=e%>
    <%
    %>          
    </body>
    </html>
    I think this will solve ur query.
    bye
    sameer

  • ? in SQL Queries and not using prepared statements

    Using EclipseLink 1.1.1
    Prepared Statements are disabled
    In our production server something went wrong and one of our Read Queries started erroring. A DatabaseException was thrown and we log the "getQuery.getSQLString()" statement. We found this query in the logs:
    SELECT t1.ID, t1.NAME, t1.DESCRIPTION, t1.EXTREFID, t1.STYLESHEET, t1.DDSVNVERSION, t1.FIRSTNAME, t1.LASTNAME, t1.EMAILADDR, t1.PHONENUMBER, t1.ADDRESS, t1.ADDRESS2, t1.CITY, t1.STATE, t1.POSTALCODE, t1.COUNTRY, t1.ADMINACCTNAME, t1.HASDOCUMENTS, t1.HASTIMEDNOTIFICATIONS, t1.STATUS, t1.ENTRYDATE, t1.EVALEXPDATE, t1.LASTREMINDDATE, t1.FULLUSERS, t1.LIMUSERS, t1.REQUSERS, t1.ISENTERPRISE, t1.EXPDATE, t1.ISDISABLED, t1.DISABLEDDATE, t1.NEEDLICENSEAGREEMENT, t1.ISWARNINGDISABLED, t1.LOCALE, t1.TIMEZONE, t1.CURRENCY, t1.DOMAIN, t1.DOCUMENTSIZE, t1.EXTRADOCUMENTSTORAGE, t1.ONDEMANDOPTIONS, t1.SSOTYPE, t1.RESELLERID, t1.ACCOUNTREPID, t1.LASTUSAGEREPORTDATE, t1.NEXTUSAGEREPORTDATE, t1.USAGEREPORTATTEMPTS FROM T_SSOOPTIONS t0, T_CUSTOMERS t1 WHERE *((((t0.SSOENABLED = ?) AND (t1.SSOTYPE IN (?, ?))) AND (UPPER(t1.DOMAIN) = ?)) AND (t0.CUSTOMERID = t1.ID))*
    Notice the values weren't entered into the where clause. We had to bounce the application to fix the problem. I've never seen this before. I've added more debugging statements to the code - so if this happens again in the future I'll have more information to report on. In the mean time I'm wondering if anyone else has every seen a problem of this nature.

    Database error due to invalid SQL statement.
    I don't have a stack, we were catching the exception and not printing the stack :(
    Like I mentioned in my first post, I added more debugging code (e.printStackTrace()). I understand this is hard to track down without more information. I was just hoping you guys had seen something like this before and had any insight. Like I mentioned before: this is on our production server. I've never seen this type of error before. That particular server (we run in a cluster mode) had been up for several days and then started generating that error. IT bounced the node and everything went back to normal. We have been using toplink for about 5 years now and have never seen this problem, until August 3rd 2009. The only thing that has changed recently is our migration from toplink 10 to EclipseLink. I was wondering if anyone knows if anything had changed in EclipseLink/toplink 11 with the generation of SQL queries.
    I'll keep looking. There is more debugging code in there now. Since the error was "Database error due to invalid SQL statement" this implies the SQL was generated, exited that part of the code and was sent to the db where it failed. I'm afraid the printStackTrace won't help if this error happens again.

  • Generating XML from SQL queries and saving to an xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    If you are using 9iR2 you do not need to do any of this..
    You can create an XML as an XMLType using the new SQL/XML operators. You can insert this XML into the XML DB repository using DBMS_XDB.createResource. You can then access the document from the resource. You can also return the XMLType containing the XML directly from the PL/SQL Procedure.

  • Generating XML from SQL queries and saving to a xml file?

    Hi there,
    I was wondering if somebody could help with regards to the following:
    Generating XML from SQL queries and saving to a xml file?
    We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
    is accessed by our software on the client machine).
    Using this order number we do a couple of SQL queries.
    My first question: What would be our best option to convert the result of the
    queries to xml?
    Second Question: Once the XML has been generated, how do we save that XML to a file?
    (The XML file is going to be saved on the file system of the server that
    the database is running on.)
    Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
    Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
    the client hard drive.
    Any information would be greatly appreciated.
    Thanking you,
    Francois

    Hi
    Here is an example of some code that i am using on Oracle 817.
    The create_file procedure is the one that creates the file.
    The orher procedures are utility procedures that can be used with any XML file.
    PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
    pi_root_tag IN VARCHAR2,
                                            po_root_element OUT xmldom.domelement,
                                            po_root_node OUT xmldom.domnode,
                                            pi_doctype_url IN VARCHAR2) IS
    xmldoc xmldom.DOMDocument;
    root xmldom.domnode;
    root_node xmldom.domnode;
    root_element xmldom.domelement;
    record_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
    -- Create the root --
    root := xmldom.makeNode(xmldoc);
    -- Create the root element in the file --
    create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
    po_xmldoc := xmldoc;
    po_root_node := root_node;
    po_root_element := root_element;
    END create_file_with_root;
    PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
    pi_element_name IN VARCHAR2,
                                            pi_parent_node IN xmldom.domnode,
                                            po_new_element OUT xmldom.domelement,
                                            po_new_node OUT xmldom.domnode) IS
    element xmldom.domelement;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    BEGIN
    element := xmldom.createElement(pi_xmldoc, pi_element_name);
    child_node := xmldom.makeNode(element);
    -- Append the new node to the parent --
    newelenode := xmldom.appendchild(pi_parent_node, child_node);
    po_new_node := child_node;
    po_new_element := element;
    END create_element_and_append;
    FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
    pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
    parent_node xmldom.domnode;                                   
    child_node xmldom.domnode;
    child_element xmldom.domelement;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
    parent_node := child_node;
    -- Create a text node --
    textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
    child_node := xmldom.makeNode(textele);
    -- Link the text node to the new node --
    compnode := xmldom.appendChild(parent_node, child_node);
    RETURN newelenode;
    END create_text_element;
    PROCEDURE create_file IS
    xmldoc xmldom.DOMDocument;
    root_node xmldom.domnode;
    xml_doctype xmldom.DOMDocumentType;
    root_element xmldom.domelement;
    record_element xmldom.domelement;
    record_node xmldom.domnode;
    parent_node xmldom.domnode;
    child_node xmldom.domnode;
    newelenode xmldom.DOMNode;
    textele xmldom.DOMText;
    compnode xmldom.DOMNode;
    BEGIN
    xmldoc := xmldom.newDOMDocument;
    xmldom.setVersion(xmldoc, '1.0');
    create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
    xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
    parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
    -- Create the record element in the file --
    create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
    parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
    parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
    parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
    -- write the newly created dom document into the buffer assuming it is less than 32K
    xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
    EXCEPTION
    WHEN xmldom.INDEX_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
    WHEN xmldom.DOMSTRING_SIZE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'String Size error');
    WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
    WHEN xmldom.WRONG_DOCUMENT_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
    WHEN xmldom.INVALID_CHARACTER_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
    WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
    WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
    WHEN xmldom.NOT_FOUND_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not found error');
    WHEN xmldom.NOT_SUPPORTED_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
    WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
    RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
    WHEN OTHERS THEN
    dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
    END create_file;

Maybe you are looking for