From database to jsp form drop downlist

is there a way to put database values from certain fields in the database,into the dropdown list in my jsp form?
if there is a way what do they call that method?

hi,
First you retrive the fields from database and store those values in a List or any collection.
after that write the code in jsp as like this..
<select name="list" >
<%                    
     for(int i=0;i<dblist.size();i++)
          String listitem = dblist.get(i);
%>
      <option value="<%=listitem%>">
      <%=listitem%>
<%             
%>
</select>Here dblist is a collection which contains the fields which you retrived from the database
regards,
sekhar.alla

Similar Messages

  • How to access next record from database on to form

    hi
    i have written the following piece of code to retrieve data from database oon to form...
    Try
                rset = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                query = "Select * from [@TEST]  where Code =  ('" + oform.Items.Item("6").Specific.value + "') "
                rset.DoQuery(query)
            Catch ex As Exception
                SBO_Application.MessageBox(ErrorToString)
            End Try
            '  oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
            oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
            oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
    but i can see only one record on my form controls.... i have placed on more button called " Next" so that i can access next records from DB when i click on "Next" button...
    Public Sub NextRecords()
    Try
         rset.MoveFirst()
                While Not rset.EoF
                 '   oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
                   oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
                  oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
                   rset.MoveNext()
                End While
                rset.MoveNext()
          Catch ex As Exception
               SBO_Application.MessageBox(ErrorToString)
          SBO_Application.MessageBox("Updated")
           End Try
    End sub
    i'm not able to access next records...
    plz provide me the solution and code for this how to handle this scenario....

    From your question and code sample given, I think the problem is you are seeing only the last record when pressing the next button.
    In the Next button press, you are coded such a way that it will populate the last record.
    Try removing the do..While.. loop and simply code like
    if Not rset.EoF
    rset.MoveNext()
       oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
       oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
       oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
    end if
    So when you click next, you can see the next record. Not the last record.
    Anoop

  • List of values from Database Adapter - BPM Forms

    Hi all,
    Can anyone tell me how to get list of values from Database adapter and a ServiceTask.
    As example lets say a table has Employee and Department columns.
    I want to list down all the Employees in BPM form (Select One List Box) once i provide the department to the Database Adapter.
    Is it possible from the DB Adapter?? What will be the variable type?
    Thanks,
    Nir

    Hi DanielAtwood,
    Thanks for your reply...
    Actually when i send the variable in 'WHERE Clause' in Db Adapter query it will retrieve more than one record as the output.
    I want to put that values to a 'SelectOneChoice' component and list down all the values..
    First I tried with data control. But i couldn't find the way to pass the value to the variable(in WHERE clause) to the query in data control view.
    Thanks,
    Nir

  • How to gather option values from database in jsp

    jsp experts
    my problem is that i have to populate the optional values that user has to selecet his choice .
    we could have done it by :
    <optional value="item1">item1
    <optional value="item2">item2
    </select>
    but in our database if new category of item is enlisted then what ??? ,thats why we go for populating the values from fetching from database by simple class & populate values in the optional values.
    can any one help about it

    Hi Avina,
    You need to invoke a method from your jsp file which interacts with the database. If you are following the MVC pattern which segregates the View and Contoller part, invoke the controller jsp from your View using the include tag.
    Say this is the View.jsp
    // all your initial page include statements --
    <%
    // all your java code (if necessary)
    %>
    <jsp:include page="Controller.jsp" >
    <jsp:param name="command" value="getOptionList"/>
    </jsp:include>
    <!-- all your html tags -->
    // If you are following my technique, there should be a Controller.jsp which interacts with your database thru some class which you instantiate in this jsp, which invokes some method (that is why i have passed a parameter, so that if u want to make a check you can do so - u may or may not pass the parameters - based on ur requirements).
    Code in Controller.jsp:
    <%
    // MyClass is the class which does the querying into the database.
    // obj.getOptions() is a method in that class which returns a Vector
    // containing all the options from your database.
    // Please ensure that you import the package in this jsp file, so as
    // to get the MyClass.class in this jsp.
    String getWhat = request.getParameter("command");
    if ( getWhat != null && getWhat.equalsIgnoreCase("command") ) {
    MyClass obj = new MyClass();
    java.util.Vector optionsAvailable = obj.getOptions();
    session.setAttribute("Options", optionsAvailable);
    %>
    -------------- End of Controller.jsp related work ---------------
    // Returning back to the code in the View.jsp:
    Once the including is over, the control will return to the next line of code in View.jsp. Just retrieve the data from the session:
    Continued - View.jsp
    <select name="itemsInDB">
    <option value="Select"> Select </option>
    <%
    /* Now you have a vector containing all the options from
    your database. */
    java.util.Vector vecOptions = (java.util.Vector)
    session.getAttribute("Options");
    for (int i=0; i<vecOptions.size(); i++) {
    %>
    <option value="<%=vecOptions.elementAt(i)%>"><%=vecOptions.elementAt(i)%></option>
    <%
    %>
    </select>
    Well thats all thats required. Your problem is solved. You will get a list of all the options in your database. Happy Coding

  • How to Retrieve data from database into another form ?

    Good Day!
    Am currently new at JSP. I've been studying it for awhile and still getting the hang of it. We are working on a project.
    Editing a given data. We have to retrieve the given data and post it to another form "Editing form".
    Since we can retrieve data using JSP but how are we going to post it to another form? I mean how are we going to transfer data from one form to another?
    Can anyone help me with codes please..

    The client is a web browser.
    The client submits a request (click a link, visit a form)
    The server gets to respond to this
    - look at request parameters from the client
    - access database
    - produce resulting html page
    - send page back to client.
    The standard pattern is to retrieve data from the database in java code, and then load that data into a bean.
    You then make that bean available as an attribute
    It is then available for use in your JSP - either <jsp:useBean> tag or using ${ELexpressions}
    All you can pass from the client to the server is request parameters - which are always strings.
    Draw a picture of where the information is, and the information flows. Very rarely does it go directly from one "form" to another.
    Cheers,
    evnafets

  • Display BLOB File (pdf format) from database inside Oracle Form (6i)

    hi all.
    Apologies for a primitive question owing to the fact that i m new to development. I have a requirement to display a pdf document with in an oracle form. i want to know is there any such control for that? or any hint how to go about it?
    thanks in advance

    Here I have found my jsp script...
    How I get the PDF?
    I call my script from pl/sql with
    web.show_document('http://my_server/getblob.jsp?id=' || id_from_my_blob_table || '&baza=myhost:1521:sid','_blank');
    <%@ page contentType="text/html;charset=windows-1250"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.text.*" %>
    <%@ page import="oracle.jdbc.driver.OracleDriver" %>
    <%@ page import="oracle.jdbc.driver.OracleResultSet" %>
    <%
    Connection con = null;
    Statement stmt = null;
    ResultSet rs= null;
    oracle.sql.CLOB clob = null;
    oracle.sql.BLOB blob = null;
    String datoteka = "";
    String host = "http://" + request.getHeader("host") + "/";
    %>
    <!--Peter Valencic 2003 -->
    <html>
    <head>
    <title></title>
    </head>
    <%
       String tip ="";
       String id ="";
       String baza ="";
       String shema ="";
    try
       id = request.getParameter("id");
       baza = request.getParameter("baza");
       shema = request.getParameter("shema");
       if (request.getParameter("id")== null)
          throw new Exception("id= null");
       else if(request.getParameter("id").equals(""))
          throw new Exception("id= null");
       if (request.getParameter("baza")== null)
          throw new Exception("baza= null");
       else if(request.getParameter("baza").equals(""))
          throw new Exception("baza= null");
       if (request.getParameter("shema") == null)
         shema ="";
       else if (request.getParameter("shema").equalsIgnoreCase(""))
         shema="";
       else
         shema =shema + ".";
    catch(Exception e)
       out.println("Priąlo je do napake: " + e.toString());
       return;
          try
                Class.forName("oracle.jdbc.driver.OracleDriver");
                con = DriverManager.getConnection("jdbc:oracle:thin:@"+baza,"your_user","your_password");
                stmt =con.createStatement();
                rs = stmt.executeQuery ("Select * from "+shema+"DOK_VSEBINA_DOKUMENTA_BLOB where ID="+id);
                boolean podatkib = rs.next();
                if (!podatkib)
                   out.print("<li>Ni podatkov za  ID="+id);
                   return;
                blob = ((oracle.jdbc.OracleResultSet)rs).getBLOB("VSEBINA");
                datoteka = rs.getString("NAZIV_DATOTEKE").toUpperCase();
                   File blobFile = new File(application.getRealPath("/uploads/blob")+"/"+datoteka);
                blobFile.createNewFile();
                InputStream podatki = blob.getBinaryStream();
                FileOutputStream strBlob= new FileOutputStream(blobFile);
                int size = blob.getBufferSize();
                byte[] buffer = new byte[size];
                int length = -1;
                while ((length = podatki.read(buffer)) != -1)
                   strBlob.write(buffer,0,length);
                podatki.close();
                strBlob.close();
                con.close();
                out.print("<li>"+host+"in2/uploads/blob/"+datoteka);
                   response.sendRedirect(host+"in2/uploads/blob/"+datoteka);
                //odpremo z jsp-stranjo datoteko..
                //response.sendRedirect("");
          catch(Exception blobException)
             out.print("<li>(BLOB)Napaka pri prebiranju podatkov:</li>"+blobException.toString());
             return;
    out.println("konec..");
    %>
    <body>
    <form method="post">
    Vnesi ID
    <input type=text name="id">
    <li> <input type=submit name="potrdi" >
    </form>
    </body>
    </html>If you look my "old" script..
    first it get 2 parameters baza= database (ip:port:sid), id= id from my table (PK)
    at the end of my script I have:
    response.sendRedirect(host+"in2/uploads/blob/"+datoteka);
    this redirect will redirect you to your file stored on server side..
    Because IE knows what file it must open it will open it with PDF reader...
    hope this help you..
    Edited by: peterv6i.blogspot.com on May 14, 2012 11:14 AM

  • Help needed: clarifying the use of beans to pass data from database to JSP

    Hi everyone,
    I am sure you all get fed up with being asked this question as I can see it is asked a lot when googled, but the answers given have not cleared things up for me.
    Anyway, I have a JSP page that contains a text box, submit button and a select box of size 10. The user enters a search string and the form submits the data and reloads the same page. From the code you can see the Name property of the bean is set.
    <jsp:useBean id="vtm" class="FinalYearProject.Types.VtmType" scope="page" />
    <jsp:setProperty name="vtm" property="NM" value="${param.NM}" />I then need to be able to use that name to query a postgresql database. I have a JDBCConnector class with the method:
        public ResultSet searchTable(String NM ) throws SQLException {
            String[] names = NM.split(" ");
            NM = "";
            for(int i = 0; i < names.length; i++) {
                NM = names[i] + "%";
            return stat.executeQuery("SELECT * FROM vtm WHERE nm ILIKE '" + NM + "';");
        }This method however can be changed.
    My question really is what is the best way for me to take the name, get the resultset and pass back the VtmType objects to the jsp so that I can populate my select box, and where should each part be handled i.e. the JSP page, the VtmType, the JDBCConnector.
    I may be going about it completely the wrong way and using beans incorrectly, but I just cant seem to get my head around the problem.
    Any help would be much appreciated,
    Thanks.

    Hi,
    Thanks for the help, I actually found some literature about the JSP Model 2 and realised that was what I needed to do. I have now re-written everything and it has made my life a lot eaiser, typically this was before I checked back on this post though!
    Anyway, I now have JSP pages requesting Servlets which create beans and call classes that access the database. The servlet then forwards the beans and where necessary a small of html to another JSP. Like you have suggested.
    One problem I have now however, is that the user needs to be logged in to access some of the pages. An error page with the correct message is displayed to the user when it is processed via the servlet.
    //Servlet detects an error
    request.setAttribute("errorMsg", "1");
    gotoPage("/loginError.jsp", request, response);
    //JSP detects which errorMsg to display
    <c:set var="errorMsg" value="${requestScope.errorMsg}" />However, when the user does not sign in and clicks a link which is blocked the JSP forwards directly to the error JSP.
    //Tests to see if user is logged in
    <c:if test="${empty user.username}">
        <jsp:forward page="/loginError.jsp">
            <jsp:param name="errorMsg" value="3" />
        </jsp:forward>
    </c:if>The problem with this is that the only way I can see of checking the errorMsg type is with:
    //JSP checks which errorMsg to display
    <c:set var="errorMsg" value="${param.errorMsg}" />Which is different to how I determine the errorMsg from the Servlet. Is there a way of getting the errorMsg type that is the same for both actions?
    Thanks.

  • Display values from database in jsp page

    Hi,
    I need to display a list of options with checkboxes in a jsp page .The values are retrived from DB.
    formBean fb=new FormBean(request)
    <Input type="checkbox" name="xyz" value="<%=fb.getFormdata( "xyz")%>">
    should this"xyz" be the name of the column in the DB table?

    This is my FormBean
    public class FormBean {
    HttpServletRequest _request;
    public FormBean(HttpServletRequest request) {
    _request = request;
    public String getFormData(String abc) {
    return getFormData(abc, true);
    public String getFormData(String name, boolean filter) {
    String value = null;
    if (_request != null) {
    value = _request.getParameter(abc);
    if (value == null) value = "";
    if (filter) {
    value = Utils.filter(value);
    return value;
    * "Clears" parameters. Useful if you do wnat a form initialized with blanks rather than
    * current values;
    public void clear() {
    _request = null;
    }

  • How do I save multiple files from database using oracle forms?

    Forms [32 Bit] Version 10.1.2.3.0 (Production)
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    Hello,
    I have a form containing a block of records with files set up in a tabular layout. Each row has a checkbox to indicate if that row is selected. What I want to do is allow the user to save each file from checked rows to a directory of their choice on their machine when a button is pressed. Is it possible to do this in one command at the same time using WEBUTIL_FILE to save all the selected files to the same directory, or would I need to loop through each row and call the save dialog each time?
    Thanks.

    I'm not sure I follow. The SAVE_DIALOG is building the path including the filename where the files will be saved. If I have 5 different files I want to save at the same time and only show the dialog once, I will only have a path for one of the files. How could I loop through the rest afterwards?

  • Invalid File after Downloading from Database using JSP/JDev 10.1.2

    Hi, i got a problem when i download a file from my blobColumn in database.
    Well, actually i got no problem in reading the file out of database, but when i download this file, there are 3 more bytes then in the original one in Database...
    Here's my java-code in the jsp-page i used as "save as" field:
    Hashtable ht = Dokument.createDOK(request);
    String dateiname = (String)ht.get("Dateiname");
    byte[] fileBytes = (byte[])ht.get("Dokument");
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    ba.write(fileBytes);
    // RESPONSE
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition","attachment; filename=\"" + dateiname + "\"");
    // DOWNLOAD
    OutputStream outs = response.getOutputStream();
    ba.writeTo(outs);
    outs.flush();
    outs.close();
    }catch(Exception ex){
    ex.printStackTrace();
    for testing i used a simple text file with 28bytes:
    begin----
    Test Zeile 1.
    Test Zeile 2.
    end-------
    after downloading this file it looks like:
    begin----
    Test Zeile 1.
    Test Zeile 2.
    end-------
    There are 3 bytes 0A(hex) at the beginning...
    I dont know why.
    after closing "outs" i made system.out for checking the amount of bytes in "fileBytes"-Array, and it was correct, just the 28 bytes like in the file from the Database.
    But i actually dont get, why there are 3 more bytes at the beginning after downloading it.
    The main problem is, some other files like word or excel documents cannt be opened, because of this 3 bytes at the beginning, and they seem to be invalid.
    Would be glad if someone can help me, got really stuck and have no idea any more.
    Thanks
    Sebastian

    Dont someone has a solution, or got a similar problem ?
    Thought about it could be a bug in the basic java classes of JDev 10.1.2
    but i dont really know...
    Have no idea left.
    Sebastian

  • Populate the JSP's select box from database on jsp load

    hai all,
    can any one help me in knowing how to populate the select box of a jsp
    with data from the database?
    thanks and regards,
    ravikiran

    <%
    String sQuery = "select id,Name from tablename";
    rs = stmt.executeQuery(sQuery);
    %>
    <select name="sltName">
    <%
    while(rs.next()){
    String sId = rs.getString(1);
    String sName = rs.getString(2);
    %>
    <option value="<%=sId %>" > <%=sName %> </option>
    <%
    %>
    </select>

  • Viewing Images from Database using JSP/ SQLJ

    Dear Friends,
    I could manage to write an image into a BLOB Field in the Oracle
    Database. I could even manage to read that image from the
    database but i am doing it by reading the BLOB data and writing
    it into a file with 'gif' or 'jpeg' extension.
    I would like to know how to read the BLOB data dynamically in
    cache and display it on the JSP page in the browser without
    creating a file on the disk.
    Thanking you,
    Sarwottam

    Thanks for replying,
    Can you please elaborate on your suggestions ?
    If possible can you provide a sample code that would help me understand better?
    Thanks again.
    Sarwottam

  • Getting error in accessing data from database thro' JSP.

    Hi,
    I tried with getting data from the database and it doesnt work fine. I am attaching the code as inline below. can anyone suggest me whats the problem.
    <html>
    <head>
    <title> Display Records </title>
    </head>
    <%@ page language="java" import="java.sql.*"%>
    <body>
    <form name="frm" method="post">
    <table border=2 cellpadding=3 cellspacing=3>
    <tr>
    <th>User ID </th>
    <th>Password </th>
    </tr>
    <%
         try
              Class.forName("org.gjt.mm.mysql.Driver");
         catch(ClassNotFoundException ex)
              ex.printStackTrace();
         try
              Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbmaintain","root","");
              Statement stm = con.createStatement();
              //String str = "select * from userpwd";
              ResultSet rs = stm.executeQuery("select * from userpwd");
              if (rs != null)
                   while (rs.next())
                        String uname = rs.getString("userid");
                        String pwd = rs.getString("password");
    %>
    <tr>
    <td><%=uname%></td>
    <td><%=pwd%></td>
    </tr>
    <%
                   }//end of while
              }//end of if
         catch(SQLException ex)
              ex.printStackTrace();
    %>
    </table>
    </form>
    </body>
    </html>
    Thanks in Advance,
    Michael.

    Hi I have stored the list of username and their
    corresponding password. I need to list all the
    username and the password in the table. Thats my
    expectation. OK.
    I dont have any error message in the
    program In case of exceptions, you indeed are not sending any error messages to the application.

  • Export to Excel from Database using JSP

    Hi Experts,
    I'm using below jsp code to export from an Oracle table to Excel using JSP.
    Every time I run this code I get the exception - "java.lang.OutOfMemoryError: Java heap space".
    I need to download around 8000+ records of the table containing 60 columns.
    I have increased Heap space but still the exception. Below is the code for your reference (I have mentioned only 30 columns where as there are 60 columns in actual). Pls help me what could be the other possible ways or suggest me any alternate code.
    Pls note - Some of the terms like "<serverip>", MySchema, myfile, COL names are changed for confidentiality.
    "D:\\Myfolder\\Excelfolder\\Final.xls" exists my the local machine.
    The code works until some 4000 records & after that throws the exception.
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@<serverip>:1521:WISTGDEV", "user", "user@123");
    Statement statement = connection.createStatement();
    String filename = "C:\\Myfolder\\Excelfolder\\Final.xls";
    String strQuery1 = ("select * from Myschema.myfile");
    ResultSet rs = statement.executeQuery(strQuery1);
    HSSFWorkbook hwb = new HSSFWorkbook();
    HSSFSheet sheet = hwb.createSheet("sheet1");
    HSSFRow rowhead = sheet.createRow((short)0);
    rowhead.createCell((short) 0).setCellValue("COL1");
    rowhead.createCell((short) 1).setCellValue("COL2");
    rowhead.createCell((short) 2).setCellValue("COL3");
    rowhead.createCell((short) 3).setCellValue("COL4");
    rowhead.createCell((short) 4).setCellValue("COL5");
    rowhead.createCell((short) 5).setCellValue("COL6");
    rowhead.createCell((short) 6).setCellValue("COL7");
    rowhead.createCell((short) 7).setCellValue("COL8");
    rowhead.createCell((short) 8).setCellValue("COL9");
    rowhead.createCell((short) 9).setCellValue("COL10");
    rowhead.createCell((short) 10).setCellValue("COL11");
    rowhead.createCell((short) 11).setCellValue("COL12");
    rowhead.createCell((short) 12).setCellValue("COL13");
    rowhead.createCell((short) 13).setCellValue("COL14");
    rowhead.createCell((short) 14).setCellValue("COL15");
    rowhead.createCell((short) 15).setCellValue("COL16");
    rowhead.createCell((short) 16).setCellValue("COL17");
    rowhead.createCell((short) 17).setCellValue("COL18");
    rowhead.createCell((short) 18).setCellValue("COL19");
    rowhead.createCell((short) 19).setCellValue("COL20");
    rowhead.createCell((short) 20).setCellValue("COL21");
    rowhead.createCell((short) 21).setCellValue("COL22");
    rowhead.createCell((short) 22).setCellValue("COL23");
    rowhead.createCell((short) 23).setCellValue("COL24");
    rowhead.createCell((short) 24).setCellValue("COL25");
    rowhead.createCell((short) 25).setCellValue("COL26");
    rowhead.createCell((short) 26).setCellValue("COL27");
    rowhead.createCell((short) 27).setCellValue("COL28");
    rowhead.createCell((short) 28).setCellValue("COL29");
    rowhead.createCell((short) 29).setCellValue("COL30");
    int index=1
    String name="";
    while(rs.next())
    System.out.println("Inside while");
    HSSFRow row = sheet.createRow((short)index);
    row.createCell((short) 0).setCellValue(rs.getString(2));
    row.createCell((short) 1).setCellValue(rs.getString(3));
    row.createCell((short) 2).setCellValue(rs.getString(4));
    row.createCell((short) 13).setCellValue(rs.getFloat(5));
    row.createCell((short) 4).setCellValue(rs.getString(6));
    row.createCell((short) 5).setCellValue(rs.getString(7));
    row.createCell((short) 6).setCellValue(rs.getInt(8));
    row.createCell((short) 7).setCellValue(rs.getString(9));
    row.createCell((short) 8).setCellValue(rs.getString(10));
    row.createCell((short) 9).setCellValue(rs.getString(11));
    row.createCell((short) 10).setCellValue(rs.getString(12));
    row.createCell((short) 11).setCellValue(rs.getFloat(13));
    row.createCell((short) 12).setCellValue(rs.getFloat(14));
    row.createCell((short) 13).setCellValue(rs.getFloat(15));
    row.createCell((short) 14).setCellValue(rs.getFloat(16));
    row.createCell((short) 15).setCellValue(rs.getFloat(17));
    row.createCell((short) 16).setCellValue(rs.getFloat(18));
    row.createCell((short) 17).setCellValue(rs.getFloat(19));
    row.createCell((short) 18).setCellValue(rs.getFloat(20));
    row.createCell((short) 19).setCellValue(rs.getFloat(21));
    row.createCell((short) 20).setCellValue(rs.getFloat(22));
    row.createCell((short) 21).setCellValue(rs.getString(23));
    row.createCell((short) 22).setCellValue(rs.getString(24));
    row.createCell((short) 23).setCellValue(rs.getString(25));
    row.createCell((short) 24).setCellValue(rs.getString(26));
    row.createCell((short) 25).setCellValue(rs.getString(27));
    row.createCell((short) 26).setCellValue(rs.getString(28));
    row.createCell((short) 27).setCellValue(rs.getString(29));
    row.createCell((short) 28).setCellValue(rs.getString(30));
    index++;
    rs.close();
    FileOutputStream fileOut = new FileOutputStream(filename);
    hwb.write(fileOut);
    fileOut.close();
    connection.close();
    catch(Exception e)
    System.out.println(e.getMessage());
    e.printStackTrace();
    Thanks in advance,
    Venky
    Edited by: Venky_86 on Apr 15, 2009 12:06 AM

    Its is an obvious thing...POI is known to need a lot of memory (the reason for that is most likely the OLE document format, which is quite complex).
    I would have used something like the below to see if that can address my client's requirement.
    public exportExcel(String fileName){
       Connection connection = null;
       Statement statement = null;
       ResultSet rs = null;
       PrintWriter out = null;
       int index=1;
       try{
         out = new PrintWrite(new FileWriter(fileName));
         connection = DbUtils.getConnection();
         statement = connection.createStatement();
         rs = statement.executeQuery("select * from Myschema.myfile");
         out.prinln("<table>");
         out.println("<th>COL1</th>");
         out.println("<th>COL2</th>");
         out.println("<th>COL3</th>");
         out.println("<th>COL4</th>");
         out.println("<th>COL5</th>");
         out.println("<th>COL6</th>");
         out.println("<th>COL7</th>");
         out.println("<th>COL8</th>");
         out.println("<th>COL9</th>");
        out.println("<th>COL30</th>");
         out.println("<thead>");
         out.println("<tbody>");
         while(rs.next()){
              out.println("<td>"+index+"</td>");
              out.println("<td>"+rs.getString(2)+"<td>");        
              out.println("<td>"+rs.getString(3)+"<td>");        
              out.println("<td>"+rs.getString(4)+"<td>");        
              out.println("<td>"+rs.getString(5)+"<td>");        
              out.println("<td>"+rs.getString(6)+"<td>");        
              out.println("<td>"+rs.getString(7)+"<td>");        
              out.println("<td>"+rs.getString(8)+"<td>");        
              out.println("<td>"+rs.getString(9)+"<td>");        
              out.println("<td>"+rs.getString(30)+"<td>");        
         out.println("</tbody>")     
         out.println("</table>");    
         out.flush(); 
       }catch(Exception exp){
           exp.printStackTrace();
       }finally{
           if(out != null)
            try{out.close();}catch(Exception e){}
             if(rs != null)
               try{rs.close();}catch(Exception e){}
            if(statement != null)
               try{statement.close();}catch(Exception e){}
             if(connection != null)
               try{connection.close();}catch(Exception e){}
    }and you can simply export the file using the method
    ApplicationUtils.getInstance().exportExcel("c:/export/myapp/ApplicationTable.xls");If you are using Office 2000 and above you should able open it as an excel worksheet without any problems.
    Hope that help :)
    REGARDS,
    RaHuL

  • Fetch Data from Database using JSP

    Dear friends,
    I am developing a portal for my College. The theme is to automate student details.
    Here i have Screens for Posting, Editing , Viewing.
    In Editing: I fetch the data from the backend using select query.
    In the address field: I have value as "Big House".
    The user keyed with double quotes when he keyed.
    During extraction of the data i put the value inside a textbox as
    <input type=text name=st1 value="<%=res.getString("street1")%>">
    Here,
    the value becomes as
    <input type=text name=st1 value=""Big House "">
    Here, you can notice that Big house i prefixed by double -double quotes.
    The value should be Big House but the values is empty.
    What i should. ???
    Thanks in Advance.
    Rengaraj.R

    Try this:
    <%
    String addr = res.getString("street1");
    //escape the double quotes from the address
    addr = addr.replaceAll("[\"]",""");
    %>
    <input type="text" name="st1" value="<%=addr%>">

Maybe you are looking for