Problem when printing the records of database

Hi all,
Although I can use the PrinterJob class to print the records of certain table in database directly to printer, it is difficult to deal with the different length of fields between different records so that, say, the first field of some records overlap with the second field when printing.
I find any layout/table method in java cannot be used in the PrinterJob class, only Graphics can be used. Does anyone know how to print the database in a good way?
thanks!

Perhaps java.text.MessageFormat is what you're looking for.
Note that in v1.4 there's also the new Java Print Service API (javax.print). (I haven't used it yet).
Greets
Puce

Similar Messages

  • Problem in printing the data from database when i print inside servlet

    hi to all!
    the objective of the code below is getting the data from database table and has to send that data to the web browser using out.println .note: out - PrintWriter object
    In a getQuestion method, i am getting the data from database table and store it in String q and when i print the q within this method it is getting printed, but i got the null value when i printed the String q inside service method doPost. why..? its puzzling me.
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              new test().connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
    out.println("<head>");
         out.println("<title>" + "shock!!!" + "</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>"+"Read twice before u answer"+"<h2>");
    out.println("<p></p>");
    //why the value of q is not getting printed, instead i get null
    out.println("<h2>"+ q +"<h2>");
    out.println("how is it");
    out.println("</body>");
    out.println("</html>");
    Edited by: Mahesh_yeswecan on Nov 29, 2008 10:42 AM

    As u said , i have done a silly mistake earlier. though i have corrected the code still i am getting the same null value
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet  {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
            out.println("<head>");
             out.println("<title>" + "shock!!!" + "</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h2>"+"Read twice before u answer"+"<h2>");
            out.println("<p></p>");
            //why the value of q is not getting printed, instead i get null
            out.println("<h2>"+ q +"<h2>");
            out.println("how is it");
            out.println("</body>");
            out.println("</html>");
    }

  • Problem when printing the report

    Hi,
    we have installed oralce 10g server.and created the reports all the formats are supporting by the server.if you give the direct printer option printer is printing junk values . any body help me on this.

    Hi,
    How many portlets are there in your page.
    Are you printing the report portlets ?
    Could you explain little bit clearly ?
    Regards,
    Vijay.B

  • Problem when printing " " using XSL

    I have a problem when printing the "<" .It is always printed as
    "&#60;" in the HTML file.
    I wish to transfer a Javascript text . I tried
    using CDATA . This is an extract of a portion in my XSL File
    which uses CDATA.
    <![CDATA[
    function createLOV(lov_name, array_touse) {
    document.writeln("<select name='" + lov_name + "'>");
    for (var i=0; i < array_touse.length; i++) {
    document.writeln("<option value='" + array_touse[i] + "'>" +
    array_touse[i] + "</option>");
    }]]>
    And this is what the HTML file contains
    function createLOV(lov_name, array_touse) {
    document.writeln("&#60;select name='" + lov_name + "'>");
    for (var i=0; i &#60; array_touse.length; i++) {
    document.writeln("&#60;option value='" + array_touse[i] + "'>" +
    array_touse[i] + "&#60;/option>"); }
    document.writeln("&#60;/select>");}
    I tried using the <xsl:text disable-output-escaping="yes"> but in
    vain.
    If i use < or &x3C; , i still get &#60; in the HTML file.
    How do I solve this problem. I'm using XSQL Servlet with JSDK2.1
    both running on Sun Solaris2.6 .
    Thanks in advance,
    Suresh
    null

    Suresh Seetharam (guest) wrote:
    : I have a problem when printing the "<" .It is always printed
    as
    : "&#60;" in the HTML file.
    : I wish to transfer a Javascript text . I tried
    : using CDATA . This is an extract of a portion in my XSL File
    : which uses CDATA.
    : <![CDATA[
    : function createLOV(lov_name, array_touse) {
    : document.writeln("<select name='" + lov_name + "'>");
    : for (var i=0; i < array_touse.length; i++) {
    : document.writeln("<option value='" + array_touse[i] + "'>" +
    : array_touse[i] + "</option>");
    : }]]>
    : And this is what the HTML file contains
    : function createLOV(lov_name, array_touse) {
    : document.writeln("&#60;select name='" + lov_name + "'>");
    : for (var i=0; i &#60; array_touse.length; i++) {
    : document.writeln("&#60;option value='" + array_touse[i] + "'>"
    +
    : array_touse[i] + "&#60;/option>"); }
    : document.writeln("&#60;/select>");}
    : I tried using the <xsl:text disable-output-escaping="yes"> but
    in
    : vain.
    : If i use < or &x3C; , i still get &#60; in the HTML file.
    : How do I solve this problem. I'm using XSQL Servlet with
    JSDK2.1
    : both running on Sun Solaris2.6 .
    : Thanks in advance,
    : Suresh
    Currently, the parser does not support the xsl:output and
    output-escaping mechanisms. We plan on adding support for this
    in a future release.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • How to print all records in database ?

    Hello,
    I am developing a small Database System. Which is used to store some information about student and then print that record, which I want to print. I have used JPanel for Printing single record. As like When I insert student id in TextBox. which is unique. then Click on Search button that is use for searching Record from database. After that the information shown in belowing JPanel. Then using one button for printing this record. It is printing only one record that I have searched. Now what is the problem, I want to print All record from database(can be 500 or 5000) without mentioning any student id in textbox.
    Any type of help Appreciated.
    Thanks in advance.
    Manveer

    Hello Manveer,
    your problem is neither Swing-related or in any other way java specific.
    If you manage to get the data of one student, excellent. Now modify your db-query in the way that the result set returns all students. Loop over the result set and print as usual.

  • Performance problem when printing - table TSPEVJOB big size

    Hi,
    in a SAP ERP system there is performance problem when printing because table TSPEVJOB has many millions of entries.
    This table has reached a considerable size (about 90 Gb); db size is 200 Gb.
    Standard reports have been scheduled correctly and kernel of SAP ERP system is updated.
    I've tried to scheduled report RSPO1041 (instead of RSPO0041) to reduce entries but it is not possible run it during normal operations because it locks the printing system.
    Do you know why this table has increased ?
    Are there any reports to clean this table or other methods ?
    Thanks.
    Maurizio Manera

    Dear,
    Please see the Note 706478 - Preventing Basis tables from increasing considerably and
    Note 195157 - Application log: Deletion of logs.
    Note 1566659 - Table TSPEVJOB is filled excessively
    Note 1293472 - Spool work process hangs on semaphore 43
    Note 1362343 - Deadlocks in table TSP02 and TSPEVJOB
    Note 996455 - Deadlocks on TSP02 or TSPEVJOB when you delete
    For more information see the below link as,
    http://www.sqlservercurry.com/2008/04/how-to-delete-records-from-large-table.html
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91179
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=83525
    If any doubts Let me know.
    Thomas
    Edited by: thomas_raja on Aug 7, 2011 12:29 PM

  • How to avoid the split problem when uploading the data from csv file

    Dear Friends,
                  I have to upload data from the .csv file to my custom table , i have found a problem when uploading the data .
    i am using the code as below , please suggest me what i have to do in this regard
          SPLIT wa_raw_csv  AT ',' INTO
                    wa_empdata_csv-status
                     wa_empdata_csv-userid
                     wa_empdata_csv-username
                     wa_empdata_csv-Title
                     wa_empdata_csv-department.
    APPEND wa_empdata_csv TO  itab.
    in the flat file i can see for one of the record for the field Title  as
    Director, Finance - NAR............there by through my code the  wa_empdata_csv-Title is getting splited data as "Director, and  Department field is getting Finance - NAR" , i can see that even though  " Director, Finance - NAR"  is one word it is getting split .
    .......which is the problem iam facing.Please could any body let me know how in this case i should handle in my code that this word
    "Director,Finance - NAR"   wil not be split into two words.
    Thanks & Records
    Madhuri

    Hi Madhuri,
    Best way to avoid such problem is to use TAB delimited file instead of comma separated data. Generally TAB does not appear in data.
    If you are generating the file, use tab instead of comma.
    If you cannot modify the format of file and data length in file is fixed character, you will need to define the structure and then move data in fixed length structure.
    Regards,
    Mohaiyuddin

  • How to change annotation's appearance  when printing the annotation under Adobe Reader?

      I'm developping a plugin under SDK 7.0 for Adobe Reader  . I have two problems.
      1)I will change annotation's appearance  when printing the annotation. How to do under Adobe Reader?
        Uunder Adobe Arobat,I use PDRegisterAnnotHandler to register GetPrintAppearance,but PDRegisterAnnotHandler does not work under Adobe Reader.
      2)Under Adobe Reader ,app.execMenuItem doesnt work.How to execute menuItem using JavaScript under Adobe Reader?
    Please Help,had better give me sample,thank.

    app.execMenuItem most certainly does work with Reader - what problems are you running into trying to use it?
    As for developing Reader plug-ins - yes, some of the SDK methods aren't available to Reader.  If you want to change the appearance of an annotation in Reader, you would need to acquire the Cos object of that annotation and modify its appearance dictionary manually.

  • I have a problem when installing the Developer Suite

    Hello,
    I'm new to Oracle and I'm having a problem when installing the Developer Suite 10g. I have the Oracle Database 11g installed, but when I try to istall the developer, it gives me this error: "Oracle Developer Suite 10g cannot be installed into an existing Oracle9i 9.2.0.1.0 oe higher Oracle Home", Although I have installed the same thing twice before and it was working.
    Please help me with this :(

    Hi user;
    I'm new to Oracle and I'm having a problem when installing the Developer Suite 10g. I have the Oracle Database 11g installed, but when I try to istall the developer, it gives me this error: "Oracle Developer Suite 10g cannot be installed into an existing Oracle9i 9.2.0.1.0 oe higher Oracle Home", Although I have installed the same thing twice before and it was working.What is your OS? If you are linux-unix level you are making installation wiht same user of Oracle Db11g? Did you try to create new Oracle_home and set it before start installation?
    Regard
    Helios

  • Problems when printing Sapscript...

    We have imported a number Sapscripts in Russian into our unicode system. Looking at the Sapscript I can see Russian text in both the first and next page of the form. However, when printing the first page looks perfect and displays in Russian, however, the second page shows hashes (#) where the Russian text should be.
    If none of it worked I might be able to understand what was going on, but when the first page prints fine I find it difficult to understand what is going on.
    I have run a check agianst both pages in SE71 and re-activated, but still no joy. What could be going wrong?.
    Gary

    Thanks guys, I have now found out what the problem was.
    All my test data was set up for me by the functional guys. The output messages that were repeated were originally set  to language of English rather than Russian, and hence the problem.
    Apologies everyone.
    Regards
    Gary King

  • Problems when printing help topics from OHJ

    We have encountered some persistent problems when printing help topics from Oracle Help for Java (Ice Browser).
    NOTE: When we print the same source files from Oracle Help for the Web, the printing problems are gone.
    (1) Spacing Errors (all printers had identical results)
    Text with special formatting (<b>, <i>) often has either too much space or not enough space.
    Links often have extra spaces underlined before or after the link, itself.
    (2) When printing multiple help topics from the TOC (an entire branch in the tree):
    On some printers, no graphics print correctly, but instead print as one of the following: 1. empty box the size of one character, 2. black box the size of one character, 3. black box the size of the original graphic. We could not detect a pattern that caused 1, 2, or 3.
    NOTE: all graphics are bit maps (screen captures) that were generated in the same manner.
    NOTE: if these same help topics are printed one at a time form Oracle Help for Java, the graphics print fine.
    Is this a problem with the Ice Browser?
    Thanks for the help,
    Wendy Studinski

    There are a known issue with the ICEBrowser printing in some circumstances. The laying out of text by the ICE Browser relies on font metrics (being able to measure the width of a run of text in a given font). On screen it looks great, but when printing, even though the GraphicsConfiguration for the printer is being used, these widths are sometimes off, which can result in text running together at boundaries between text styles. We're not sure what to do about this problem, and we've reported it to IceSoft.
    Not every font has this problem, so varying the font you are using might help the appearance when printed.
    The other problem you report, problems with the images when printing multiple topics, is something that we will look into.

  • "Problem When Printing" error on Mac Mini

    Hi all,
    I just recently updated my Mac Mini from 10.3 to 10.4. Instead of Archive and Install I formatted and did a clean install.
    I have my printer set up, however whenever I try and print anything from any application I get a very unhelpful "Problem when printing" error, and nothing prints.
    I also get the same error when trying to save to PDF.
    My printer is a HP Deskjet 3750, and the driver is the one included with 10.4 (as per HP's instruction), but I don't think it's a driver problem as Save to PDF gives me the same error.
    I've already tried repairing permissions. Anyone know what could be causing this. Any help is greatly appreciated.
    Thanks.

    Bugger. PSR is often a winner
    You could try installing Gutenprint 5.0.1 available from Sourceforge (it's about 15MB). It's an updated version of the included GIMP-Print drivers and may repair/replace/install some of the core files. Otherwise you may have to contact Apple and see if you can get 10.4.9 mailed to you.

  • Problem when printing booklets prints pages 1,2 and 11 as if I wants to print all

    I am using XP and 2000 MS word
    I am having a problem when printing booklets from time to time. I get it ready to print in booklet form with 12 pages and my printer gives me the options. “Print all”  “current page”  “selection” or “pages”  Because it is booklet I want to print the first 4 pages to be folded and glued as a small book. When I inter 1-4 as the example shows some times it prints OK but about a week later it prints pages 1,2 and 11 as if it wants to print all. I thought it was the printer but think it could be in some setting of the word program or my computer it self.

    Also does this (i.e. prints web pages over several pages despite changing settings) on my laptop at work with an HP printer. This started when I upgraded to Firefox 9.0.1.

  • Color management problem when printing

    (sorry for the double post, since the problem affect both illustrator and photoshop and in fact also indesign) in decided to repost it here in the photoshop forum. thank you for any help!)
    hi ! im in charge of a big print lab in a university. All macpro quad running on 10.6.4, CS5 all updated.
    i  have a major problem when printing from all 3 CS5 apps : Illustrator  (being the worst), photoshop and indesign : each one produces a  different print even if i use the SAME color management options (the  application manage color using my own color profile file created with a  i-one tool from greta macbeath and using eye-one match 3). im printing  on a XEROX 7750gx laser printer. very cool printer never had trouble  with colors before with it, in any case it was always the software part  that was causing color problems (like i suspect in this case).
    how  can 3 softwares under the same application collection and brand, using  the same color profile and options (IDENTICAL ! it's triple check all  the options!) can produce 3 different prints when printing the same  image (it's a color psd created under photoshop CS5) ?!
    i  remember having some trouble like this when we first got CS1 in our lab,  but not this bad... i've checked everything... i realy don't know how  to fix this problem...
    the best setting so far is in  Photoshop when the application manage the color and using my color  profile file in perceptual mode. best output so far, not the best i had  in the past, CS4 was way more perfect with color management.
    i  realy need to find a solition 'cause the students expect the color to  be almost perfect (and they almost were using CS4 in the past...
    thanx for any tips & help !
    +

    many thanx for your reply & help.
    i've just recalibrated everything in my workflow : my screen (perfect!), my xerox 7750 color laser printer. i've recreated a new color profile file for the xerox color. and the same thing is happening : a kind of pink color all over my prints and every adobe's applications is printing different results. in photoshop i can manage the problem when forcing to print in perceptual mode. not perfect but it's fine. and with the other software specialy like ACROBAT and INDESIGN there's no option like this so it prints very badly. only option is to print in adobe 1998 rgb or SWOP cmyk (depending of the color space of the image of course)... the image is use for my test is RGB. images in CMYK are doing the same exact thing.
    by the way for calibration is use an x-rite (greta macbeth) eye-one tool with eye-one match 3.6.3. i calibrate the screens and create color profile with this tool since ADOBE CS1 and never had this much trouble with colors...
    here's a capture from photostop CS5 print dialog. when using the option "match print colors" you can see the image with all the PINK NOISE when using the print in RELATIVE colormetric mode (at the bottom right). using perceptual is "fine" (not color perfect but OK).
    http://i53.tinypic.com/qzge12.jpg
    it's worst in Acrobat and Indesign since i can't use perceptual colormetric print mode...
    im realy starting to think that i better uninstal CS5 and go back to CS4...
    thanx for your help !

  • I am currently using Lightroom 5.6 and operating on a Mac with OSX Ver 10.9.5. I am receiving an error problem when doing the following -  I am exporting selected photos from a particular Catalogue saved on Drive 1 to a folder created on another Drive whe

    Hi, I am having a little trouble with exporting images to another drive and Catalogue and need some help if anyone can give me some advice
    I am currently using Lightroom 5.6 and operating on a Mac with OSX Ver 10.9.5.
    I am receiving an error problem when doing the following -
    I am exporting selected photos from a particular Catalogue saved on Drive 1 to a folder created on another Drive where a Lightroom Catalogue has been created. In this Catalogue I have arranged for the images once exported to be moved to a different folder - I used the Auto Import process under the File dialogue box.
    When processing the Export I receive an error message for each of the images being exported indicating the following -
    Heading Import Results
    Some import operations were not performed
    Could not move a file to requested location. (1)
    then a description of the image with file name
    Box Save As                                  Box  OK
    If I click the OK button to each image I can then go to the other Catalogue and all images are then transferred to the file as required.
    To click the OK button each time is time consuming, possibly I have missed an action or maybe you can advise an alternative method to save the time in actioning this process.
    Thanks if you can can help out.

    Thank You, but this is a gong show. Why is something that is so important to us all so very, very difficult to do?

Maybe you are looking for

  • Error handling for a save button

    hi. how do i get error handling say in a button, and then to give an error to the user, without crashing the whole application. can any one point me to any articles, tried searching , and not finding wxactly what i am looking for. thanks. http://star

  • Displaying html in Swing

    I have downloaded a weather sticker from weatherbug. If I use it in an html page, it works fine. If I use the following code to put it in a swing frame, it does not. What I am doing incorrectly? import javax.swing.JEditorPane; import javax.swing.JPan

  • Inventory Load

    Hi I am loading data for inventory .. I have 3 dataources BX, BF and UM. My question is once we complete setup table filling and loading into BI, shall we delete the contents of application area '03' every time before proceeding to setup table fillin

  • Convert Cap 7 project to Cap 8 Responsive project

    Is there a way to convert a Captivate 7 project to a Captivate 8 Responsive design project without having to rebuild the entire project? I have a number of projects that I would like to make over as responsive design projects, but don't have the time

  • Mass Creation of Company Code

    Hi, I am trying to upload 300 company code from another system into SAP. I looked into BAPI but find only COMPANYCODE_GETLIST. I would appreciate if anyone can tell me if there is anyone can tell me if there is any other way I can mass create Company