Printing Database data

Hi, i have a jsp page that attempts to connect to an oracle database and retriev data from it and print it out to the webpage concerned.
My code runs, and the webpage loads up, but i do not retrive any data, well its not printing anyway. Here is my code....
(I am using a Tomcat webserver, running on my own machine)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Testing Database Access</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6" TEXT="#000000" LINK="#0000EE"
VLINK="#551A8B" ALINK="#FF0000">
<CENTER>
<TABLE BORDER=5 BGCOLOR="#EF8429">
<TR><TH CLASS="TITLE">
Testing Database Access</TABLE>
</CENTER>
<P>
<%@ page language="java" %>
<%@ page errorPage="errorpg.jsp" %>
<%@ page import="java.util.*" %>
<%@ page import="oracle.jdbc.driver.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
Here IS what is is the Database
     <%!
          String [] set1 = new String [5000];
          String [] set2 = new String [5000];
          int i;
     %>
     <%     
          Connection conn = null;
          try
     %>
     <%
     DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
     String username = "Donnchadh", password = ".........";
     conn = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:kiwi",username,password);
     java.sql.Statement stmt = conn.createStatement();
     String query1 = ("SELECT * FROM BOOKINGS;");
     ResultSet rs = stmt.executeQuery(query1);
     while(rs.next())
     int ccount = rs.getMetaData().getColumnCount();
     for( int i = 0; i <= ccount; i++ )
     String name = new String(rs.getString(i).getBytes("ISO-
8859-1"),"Cp1251");
     set1 = name;
for( int i = 0; i <= set1.length -1; i++ )
     out.print(set1[i]);
     java.sql.Statement stmt2 = conn.createStatement();
     String query2 = ("SELECT * FROM PERSONALS;");
ResultSet rs2 = stmt2.executeQuery(query2);
while(rs2.next())
     int ccount = rs2.getMetaData().getColumnCount();
     for( int i = 0; i <= ccount; i++ )
          set2 [i] = rs2.getString(i);
for( int i = 0; i < set2.length -1; i++ )
     out.print(set2[i]);
     %>
     <%
     if(conn != null)
          try
               conn.close();
          catch(Exception e)
               return;
     }// End Try
     catch(Exception e)
          return;
%>
<P>
</BODY>
</HTML>
Thanks for any help.

Hi again, thanks for you continued help Ravi. I have implemented the code as you suggested. And the page loads up ok, no errors, but still no data. I am sure that i have data in the database.
Here is the code i have, with the implementation that you suggested.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Testing Database Access</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6" TEXT="#000000" LINK="#0000EE"
VLINK="#551A8B" ALINK="#FF0000">
<CENTER>
<TABLE BORDER=5 BGCOLOR="#EF8429">
<TR><TH CLASS="TITLE">
Testing Database Access</TABLE>
</CENTER>
<P>
<%@ page language="java" %>
<%@ page errorPage="errorpg.jsp" %>
<%@ page import="java.util.*" %>
<%@ page import="oracle.jdbc.driver.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
Here IS what is is the Database
     <%!
          String [] set1 = new String [5000];
          String [] set2 = new String [5000];
          int i;
     %>
     <%     
          Connection conn = null;
          try
     %>
     <%
               Class.forName("oracle.jdbc.driver.OracleDriver");
               String username = "Donnchadh", password = ".........";
               conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:kiwi",username,password);
               java.sql.Statement stmt = conn.createStatement();
               String query1 = ("SELECT * FROM BOOKINGS;");
               ResultSet rs = stmt.executeQuery(query1);
               ResultSetMetaData rs_metaData = rs.getMetaData();
               int noofcolumns = rs_metaData.getColumnCount();
               Vector temp=new Vector();
               while (rs.next())
                    Object making_VectorElement[] = new Object[noofcolumns];
                    int column_count = rs_metaData.getColumnCount();
                    for(int counter = 1; counter <= column_count ; counter++)
                         making_VectorElement[counter - 1] = rs.getString(counter);
                         if(rs.wasNull()) making_VectorElement[counter - 1] = "";
                    temp.addElement(making_VectorElement);
               //then find the length of the vector and use the following code to display the elements in a table.
     %>
               <%
                    out.println("<table>");
                    out.println("</TR>");
                    Vector vresultsub=new Vector();
                    int cnt = 0;
                    while (cnt < temp.size())
                         vresultsub = (Vector)temp.elementAt(cnt);
                         out.println("<TR>");
                         for(int i = 0;i<vresultsub.size();i++)
                              if( vresultsub.elementAt(i) == null)
                                   out.println("<td> </td>");
                              else
                                   out.println("<td><font face=arial size=1>" + vresultsub.elementAt(i) + "</font></td>");
                         out.println("</TR>");
                         cnt ++;
                    out.println("</TABLE><BR>");
               %>
     <%
               if(conn != null)
                    try
                         conn.close();
                    catch(Exception e)
                         return;
          }// End Try
          catch(Exception e)
               return;
     %>
<P>
</BODY>
</HTML>

Similar Messages

  • Using htp.p for print dynamic data in apex region make my page slow?

    Hi, everyone!!! My name is Rafael, and...
    I search in the web and in this forum but i can´t find a answer for my doubt.
    Using the procedure htp.p for print dynamic data in apex region through on demand process , this will leave my webpage slow to load when the user access?
    Example:
    For build a menu in my webpage, it´s read a function in the database that returns variable string, so by a demand process this string is obtain and print in a web page using htp.p.
    I notice that this practice causes slow to load the data on the page.
    This is it...
    If someone help me, thanks...
    bye and Happy new Year!!!
    Edited by: user9518141 on 26/12/2009 17:19

    Hi,
    Try commenting out the function call and print some sample text in the htp.p like htp.p('Hello world..');
    I think the function call is probably taking a lot of time .. not htp.p.
    I have used htp.p to print out values dynamically in a lot of situations and have not ever come across any performance issues.It could be a problem with the function you are calling.
    Thanks,
    Rajesh.

  • Can we print the data from types or return it to java ?

    Hello,
    The requirement is very clear that, their is a huge amount of data (80 lacs Rows Approx.) these rows are need to be showed in the front-end which is java. First the java team had written a simple select statement in the java codeing which was taking a quite a large time (10 - 20 min approx.), then i shifted this part to back-end i,e ORACLE 11g & wrote the plsql block below which consist of types.
    Now i have managed to bring the data in types but how to print that data ??? is their any member function ???  How should i return this data to java code ???
    ORACLE DATABASE 11g
    Eclips Java
    Linux Enterprice Edition 5
    create or replace procedure date_time(v_fromtime in timestamp,v_totime in timestamp) is
    type v_date_time is table of varchar2(4000);--T_MES_DSS_BLOCK_DATA_13.Date_Time%type;
    datetime_tab v_date_time:=v_date_time();
    type v_counter is table of T_MES_DSS_BLOCK_DATA_13.Counter%type;
    counter_tab v_counter:=v_counter();
    type v_column_1 is table of number;
    column1_tab v_column_1:=v_column_1();
    type v_column_2 is table of number;
    column2_tab v_column_2:=v_column_2();
    cursor dt is
    select DATE_TIME, COUNTER,COLUMN_1, COLUMN_2
    from (
    select
    /*+  INDEX(T_MES_DSS_BLOCK_DATA_13 IDX_MES_BLK_DATA_3_DATE_TIME) INDEX(T_MES_DSS_BLOCK_DATA_13 IDX_MES_BLK_DATA_3_COUNTER)*/
    DATE_TIME, COUNTER,
    dbms_xdbutil_int.rawtonum(SUBSTR(BLOCK_COLUMN_23, 121, 8))COLUMN_1,
    dbms_xdbutil_int.rawtonum(LAG( (SUBSTR(BLOCK_COLUMN_23, 121, 8)),1,0 ) OVER (ORDER BY DATE_TIME ))COLUMN_2 
    from T_MES_DSS_BLOCK_DATA_13 PARTITION(PART11JUN2010) 
    where DATE_TIME BETWEEN v_fromtime and v_totime);
    end_time number;
    start_time number;
    begin
    start_time:=dbms_utility.get_time();
    open dt;
    loop
    fetch dt bulk collect into datetime_tab,counter_tab,column1_tab,column2_tab;
    exit when dt%notfound;
    end loop;
    close dt;
    dbms_output.put_line('Number of Rows in Date_time:- ('||datetime_tab.count||'):');
    dbms_output.put_line('Number of Rows in Counter:- ('||counter_tab.count||'):');
    dbms_output.put_line('Number of Rows in column1:- ('||column1_tab.count||'):');
    dbms_output.put_line('Number of Rows in column2:- ('||column2_tab.count||'):');
    end_time:=dbms_utility.get_time();
    dbms_output.put_line('Total Time:-'||to_char(end_time-start_time)/60);
    end date_time;

    Well anyhow i have managed to run this code using bulk collect feature & getting good performance but can i print this data ???
    how to return this data which has bulk collect feature to java code ??? any idea ?
    CREATE OR REPLACE PROCEDURE "MES01"."DATE_TIME"(v_fromtime in timestamp,v_totime in timestamp,
    datetime_tab out t_mes_dss_block_data_13.date_time%type,
    counter_tab out t_mes_dss_block_data_13.counter%type,
    column1_tab out number,
    column2_tab out number) is
    cursor dt is
    select DATE_TIME, COUNTER,COLUMN_1, COLUMN_2,rownum
    from (
    select  /*+  INDEX(T_MES_DSS_BLOCK_DATA_1 IDX_MES_BLK_DATA_1_DATE_TIME) INDEX(T_MES_DSS_BLOCK_DATA_1 IDX_MES_BLK_DATA_1_COUNTER)*/
    DATE_TIME, COUNTER,
    dbms_xdbutil_int.rawtonum(SUBSTR(BLOCK_COLUMN_1, 1, 4))COLUMN_1,
    dbms_xdbutil_int.rawtonum(LAG( (SUBSTR(BLOCK_COLUMN_1, 1, 4)),1,0 )   OVER (ORDER BY DATE_TIME ))COLUMN_2 
    from T_MES_DSS_BLOCK_DATA_1 PARTITION(PART03AUG2010) 
    where DATE_TIME BETWEEN '02-AUG-2010 09:00:00.0' and '02-AUG-2010 09:10:00.0')  
    where COLUMN_1 =0 and COLUMN_2 != 0 or (rownum=1 and COLUMN_1 = 0 and COLUMN_2 = 0);
    --end_time number;
    --start_time number;
    begin --1st block
    Declare --2nd declare
    type v_date_time is table of T_MES_DSS_BLOCK_DATA_3.DATE_TIME%type;
    datetime_tab v_date_time:=v_date_time();
    type v_counter is table of T_MES_DSS_BLOCK_DATA_3.Counter%type;
    counter_tab v_counter:=v_counter();
    type v_column_1 is table of number;
    column1_tab v_column_1:=v_column_1();
    type v_column_2 is table of number;
    column2_tab v_column_2:=v_column_2();
    type v_rownum is table of number;
    rownum_tab v_rownum:=v_rownum();
    Begin --2nd block
    --start_time:=dbms_utility.get_time();
    open dt;
    loop
    fetch dt bulk collect into datetime_tab,counter_tab,column1_tab,column2_tab,rownum_tab;
    exit when dt%notfound;
    end loop;
    close dt;
    --dbms_output.put_line('Number of Rows in Date_time:- ('||datetime_tab.count||'):');
    --dbms_output.put_line('Number of Rows in Counter:- ('||counter_tab.count||'):');
    --dbms_output.put_line('Number of Rows in column1:- ('||column1_tab.count||'):');
    --dbms_output.put_line('Number of Rows in column2:- ('||column2_tab.count||'):');
    --end_time:=dbms_utility.get_time();
    --dbms_output.put_line('Total Time:-'||to_char(end_time-start_time)/60);
    end; -- 2nd block
    end date_time; -- 1st block

  • Database Date in Reports

    Hello,
    I'm using Reports 6i.
    I want to have database date printed on the top right corner of the reports in the 'DD/MM/YYYY' format without using 'SELECT sysdate FROM dual' expression.
    Is there any alternate?
    The date that is inserted by selecting Date and Time from Insert Menu in picks up the cleints date and one cannot control a client PC's date.
    Please reply at [email protected]
    Thanx.
    HASAN.

    The reason for avoiding "SELECT SYSDATE FROM DUAL" is avert increment in network traffic...
    May be it has a negligible impact but I was trying to know if there is any alternate.
    Any way thanx for replying..
    HASAN.

  • Printing Chinese Date format using Oracle Reports

    Hi ,
    I need to print the date as for e.g, 2006 4 12 (Year Month and Day) with a chinese character after each of the three components, representing the year, Month and Day.
    When running the report with the format mask as RRRR Mon DD, I get the chinese character for the Month component and not for the year and day. I tried with different format masks available and also tried with somehting which is not in list as well. But, I couldn't get the intended format.
    Is there anyone who has done this before? If so, pl. let me know the way to get this done.
    regards,
    tilak

    Hi Olga,
    If  the Date in the database is date (not datetime) means you cannot use a DD-MON-RR HH:MI:SS in your reports.
    If you want to show date with time means, change the properties in Oracle Forms of that date field and assign datetime as datatype.
    So that the value inserted to the field will become datetime. and automatically if you use this column in your report you will get date along with time.
    Hope this clears...
    Regards,
    Soofi

  • Using Javax.print I have to print the data which are stored in resultsets.

    Using Javax.print I have to print the data which are stored in resultsets.
    Actually we ar working on a project where n numbers of records are fetched from database and stored in Resultsets. We made JSF pages which displayes the records in Web Browser.
    There is a link in that page. If we click that print link, It has to be printed all the records row by row using javax.print. It should act like Printer friendly in browser.
    Kindly send us any example code to proceed.

    Is it possible to access the cache datasource inside the script component which is available in the same data flow task??
    Thanks in advance,
    Saravanan

  • Can VC print all data in a table?

    Hello!
      Can VC print all data in a table?
    Best Reagrds!
    csquare.

    I write it in this post:
    Re: Qusetion about Table View.
    It is possible, that you have to use the paging options.
    Regards,
    Marcel

  • How to print text/data in flex 3 using printer???Plz help...

       Hi,
              plz tell me the way to print text/data using printer in flex.  I tried the FlexPrintJob class. but it takes object of a container to be printed & prints the visible content of that container(along with scrollbars), bt i want to print all contents of the container(including invisible).
          I have tried to print bitmap image through FlexPrintJob but it takes lot of time for spooling... So plz help me out in printing(fast with all content) in flash
    I am using flex 3 (flex Builder 3 IDE).
      Thanks in advance!!!

    Hi Sagar,
    Don't worry You can use the below work around to print all the contents of the Container including the invisible contents under scrolll with out scroll bar..
    So what the idea here is we are seeting the container height to full size with out scrolls before sending the container object to printer and as soon as you print the object you are restoring it to the original height with scrolls...so that you can print the full contents without scrolls...
    You may have doubt that by chnaging and restoring the size the user may see momentary resize of the container but it is not so as it is a fraction of a second and user cannot notice this change... Give it a try ..I had already run into this problem recently and I have found a work around for this which is as below:
    // Here mainContainer is the container or box id the contents of which you want to print
       private function doPrintContainer():void
        var printJob:FlexPrintJob = new FlexPrintJob();
        if(printJob.start() != true) return;
        try
         var mainContainerHeight:int = mainContainer.height;
         //Increasing the height of the desired component to be printed.
         mainContainer.height = mainContainer.measuredMinHeight;
         mainContainer.verticalScrollPolicy = "off";
         //Adding the resized Component to our FlexPrintjob and then sending the print request
         printJob.addObject(this,FlexPrintJobScaleType.MATCH_WIDTH);    
         printJob.send();
         //Resizing the component back to normal size
         mainContainer.height = mainContainerHeight;
         mainContainer.verticalScrollPolicy = "auto";    
        catch(error:Error)
                     trace("Error : " + error.message);
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • How to print formated data/report on client's printer (Web Application)

    Hi All
    I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
    Application is web based
    Technology used are Java - jsp - servlets
    i want functionality like...
    when user click on print button/link, data is fetched from server and all pages (it is formated data so i want alignment on page while printing) should be printed one after another.
    Also printer selection dialog should displayed one time when user click on print button/link.
    Questions:
    1. How i will transfer all data to client (web browser) from the server ??
    2. And how i can print that data on user's printer ??
    There is requirement (or limitation) that I can not use applet for this purpose.
    And also it is not fix that we must use java tech., we can use any othere tech. but condition is that it must support multiple platform (in short platform indipendant)
    There is solution like ...
    I can use window.print() function of DOM/JavaScript,
    but it prints only one page which is displayed on browser.
    I don't want to display any page. and want to print all pages.
    if any one done or have idea then let me know.
    Thanks in Adv.
    Shailesh Koradiya

    thanks linxpda for reply,
    we can use ActiveX component for windows platform for printing purpose, same way we can use platform specific component for printing... (for linux, unix, sun solaris etc...)
    if it is possible then let me inform.
    Thanks,
    Shailesh Koradiya

  • Printing System Date on Report Title

    How can I print the system date on the title of report generated by SQL*Plus?
    I remember it is possible to include SQL.PNO in the statement TTITLE to print the page number. Is there any variable like SQL.PNO which represent system date?
    Previously I've include SYSDATE to the SELECT statement of the report. It is the column named TODAY, with option NOPRINT and NEW_VALUE TT_TODAY, where TT_TODAY is include in TTITLE statement. The problem is: if the SELECT statement returns nothing, TT_TODAY will be blank/Null.
    How can I work around with this problem?

    Dear all,
    My colleague told me the way to print System Date on title of SQL*Plus report as followed:
    COLUMN today NEW_VALUE tt_today NOPRINT FORMAT A1 TRUNC
    TTITLE CENTER tt_today RIGHT SQL.PNO
    SET FEEDBACK OFF
    SET TERMOUT OFF
    SELECT SYSDATE AS today FROM DUAL;
    SPOOL RPTFILE
    SELECT ....... << to generate report output >> .......
    SPOOL OFF
    SET TERMOUT ON
    SET FEEDBACK ON
    It works! The output file contains System Date on each page title.
    I don't understand why Oracle didn't implement variable similar to SQL.PNO to represent the System Date. If Oracle is able to create SQL.PNO which can increment on each page break, why not the System Date which remains the same on each page?

  • How to print formatted data / report on user's printer in Web Application

    Hi All
    I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
    application is web based and tech. used are Java - jsp - servlets
    now prob. is ...
    how i will transfer all data to client (web browser) from the server and how i can print that data on user's printer ...??
    there is requirement that I can not use applet for this purpose.
    if any one done or have idea then let me know.
    thanks
    Shailesh Koradiya

    Hi
    Its simple, first of all break ur data in terms of pages. Write the logic in one JSP.
    suppose i have jsp PrintReport.jsp , for page 1 url will PrintReport.jsp?page=0 ... so on
    get the page parameter in JSP
    String page="";
    if(request.getParameter("page")!=null)
    page=request.getParameter("page");
    get the rowcount from the Result and assume records per page is 100
    if u have 1000 rows then 10 pages u have to serve
    StartRowNumber=page*recordsPerPage
    EndRowNumber=StartRowNumber+recordsPerPage
    Execute a SQL query , select * from table where rownum between
    StartRowNumber and EndRowNumber
    Provide google like pageNumbers in ur HTML page
    ie 1 2 3 4 5 6 ..10
    Regarding printing , Create HTML button called 'print' and add Javascript ' window.print()' on clicking it.
    Hope it would solve ur problem
    Cheers
    Rajendra Bandi

  • How to print the date in Horizontal way in query................

    Hiu2026u2026
    I have created a query using SQVIu2026The output is likeu2026
    Zone | Customer Group | Customer Name | Date | Value(Rs)
    East | ABC/JPR | ABC pvt ltd | 01.08.2011 | 50,000
    West | LMN/Delhi | LMN pvt ltd | 02.08.2011 | 1, 50,000
    South | PQR/Haryana | PQR auto sales p l | 03.08.2011 | 1,00,000
    My problem is i have to print the date in the format like
    Zone | Customer Group | Customer Name | 01.08.2011 | 02.08.2011 | 03.08.11 | 04.08.2011 |..............31.08.2011|
    East | ABC/JPR | ABC pvt ltd | 50000 | 150000 | 100000 | | |
    Thanks&Regards,
    Pranitha.

    Hi Pranita,
    You could try with logic:
    CONCATENATE LINES OF itab INTO warea SEPARATED BY '|'.
    BR
    Dep

  • How to print the data in the grid?

    Hi all,
    I'm new to java. So, I need some helps.
    I want to print the data in the grid. Data could be more than one page. But I have no idea how to start writing code.
    Please let me know if you know.
    Thank you.
    DT.

    Follow this steps.
    1- the Grid which you wish to print must locate in a class which implements Printable() interface.
    e.g.
    import javax.swing.table.*;
    import java.awt.print.*;
    import javax.infobus.*;
    public class myGridControl extends GridControl implements Printable{
    // add the following statements in the definition section of your class
    int m_maxNumPage =1;
    JTable m_table;
    TableModel m_tableModel;
    ScrollableRowsetAccess myRs;
    // add the folowing statemnts in the
    //constructor or init method or start method
    //(Notice:if you couldn't print, possible
    //you didn't put these stetment on the right
    //location and one or all of them
    //are "null".change the location and make
    //sure they are not null when you issue a
    //print order)
    m_table = new JTable();
    m_table = masterGrid.getTable();
    m_tableModel = m_table.getModel();
    myRs = (ScrollableRowsetAccess)masterGrid.getDataItem();
    3- add following methods to your class(myGridControl). just cut and paste.
    // Print Methods
    public void printData() {
    try {
    PrinterJob prnJob = PrinterJob.getPrinterJob();
    prnJob.setPrintable(this);
    if (!prnJob.printDialog())
    return;
    prnJob.print();
    catch (PrinterException e) {
    e.printStackTrace();
    System.err.println("Printing error: "+e.toString());
    public int print(Graphics pg, PageFormat pageFormat,int pageIndex) throws PrinterException {
    JLabel m_title=new JLabel("Alexus Report : "+titleName);
    if (pageIndex >= m_maxNumPage)
    return NO_SUCH_PAGE;
    pg.translate((int)pageFormat.getImageableX(),
    (int)pageFormat.getImageableY());
    int wPage = 0;
    int hPage = 0;
    if (pageFormat.getOrientation() == pageFormat.PORTRAIT) {
    wPage = (int)pageFormat.getImageableWidth();
    hPage = (int)pageFormat.getImageableHeight();
    else {
    wPage = (int)pageFormat.getImageableWidth();
    wPage += wPage/2;
    hPage = (int)pageFormat.getImageableHeight();
    pg.setClip(0,0,wPage,hPage);
    int y = 0;
    pg.setFont(m_title.getFont());
    pg.setColor(Color.black);
    Font fn = pg.getFont();
    FontMetrics fm = pg.getFontMetrics();
    y += fm.getAscent();
    pg.drawString(m_title.getText(), 0, y);
    y += 20; // space between title and table headers
    Font headerFont = m_table.getFont().deriveFont(Font.BOLD);
    pg.setFont(headerFont);
    fm = pg.getFontMetrics();
    TableColumnModel colModel = m_table.getColumnModel();
    int nColumns = colModel.getColumnCount();
    int x[] = new int[nColumns];
    x[0] = 0;
    int h = fm.getAscent();
    y += h; // add ascent of header font because of baseline
    // positioning (see figure 2.10)
    int nRow, nCol;
    for (nCol=0; nCol<nColumns; nCol++) {
    TableColumn tk = colModel.getColumn(nCol);
    int width = tk.getWidth();
    if (x[nCol] + width > wPage) {
    nColumns = nCol;
    break;
    if (nCol+1<nColumns)
    x[nCol+1] = x[nCol] + width;
    String title = (String)tk.getIdentifier();
    pg.drawString(title, x[nCol], y);
    pg.setFont(m_table.getFont());
    fm = pg.getFontMetrics();
    int header = y;
    h = fm.getHeight();
    int rowH = Math.max((int)(h*1.5), 10);
    int rowPerPage = (hPage-header)/rowH;
    m_maxNumPage = Math.max((int)Math.ceil(m_table.getRowCount()/
    (double)rowPerPage), 1);
    int iniRow = pageIndex*rowPerPage;
    int endRow = Math.min(m_table.getRowCount(),
    iniRow+rowPerPage);
    // take an array to store columns header
    String colNames[] = new String[nColumns];
    for (nCol=0; nCol<nColumns; nCol++) {
    colNames[nCol] = myRs.getColumnName(nCol+1).toString();
    try{
    for (nRow=iniRow; nRow<endRow; nRow++) {
    y += h;
    // set RowSet on the specific row
    myRs.absolute(nRow+1);
    for (nCol=0; nCol<nColumns; nCol++) {
    /* the next 3 lines are old code
    int col = m_table.getColumnModel().getColumn(nCol).getModelIndex();
    Object obj = m_tableModel.getValueAt(nRow, col);
    String str = obj.toString();
    // take the values column by columns
    ImmediateAccess ia = (ImmediateAccess)myRs.getColumnItem(colNames[nCol]);
    String str = ia.getValueAsString();
    if (str.equals("")) str=" ";
    /* this if is usefull if we'd like to have coloring in printing
    if (obj instanceof ColorData)
    pg.setColor(((ColorData)obj).m_color);
    else
    pg.setColor(Color.black);
    pg.drawString(str, x[nCol], y);
    }catch(Exception e){
    e.printStackTrace();
    System.gc();
    return PAGE_EXISTS;
    public void printData() {
    try {
    PrinterJob prnJob = PrinterJob.getPrinterJob();
    prnJob.setPrintable(this);
    if (!prnJob.printDialog())
    return;
    prnJob.print();
    catch (PrinterException e) {
    e.printStackTrace();
    System.err.println("Printing error: "+e.toString());
    public int print(Graphics pg, PageFormat pageFormat,int pageIndex) throws PrinterException {
    JLabel m_title=new JLabel("Alexus Report : "+titleName);
    if (pageIndex >= m_maxNumPage)
    return NO_SUCH_PAGE;
    pg.translate((int)pageFormat.getImageableX(),
    (int)pageFormat.getImageableY());
    int wPage = 0;
    int hPage = 0;
    if (pageFormat.getOrientation() == pageFormat.PORTRAIT) {
    wPage = (int)pageFormat.getImageableWidth();
    hPage = (int)pageFormat.getImageableHeight();
    else {
    wPage = (int)pageFormat.getImageableWidth();
    wPage += wPage/2;
    hPage = (int)pageFormat.getImageableHeight();
    pg.setClip(0,0,wPage,hPage);
    int y = 0;
    pg.setFont(m_title.getFont());
    pg.setColor(Color.black);
    Font fn = pg.getFont();
    FontMetrics fm = pg.getFontMetrics();
    y += fm.getAscent();
    pg.drawString(m_title.getText(), 0, y);
    y += 20; // space between title and table headers
    Font headerFont = m_table.getFont().deriveFont(Font.BOLD);
    pg.setFont(headerFont);
    fm = pg.getFontMetrics();
    TableColumnModel colModel = m_table.getColumnModel();
    int nColumns = colModel.getColumnCount();
    int x[] = new int[nColumns];
    x[0] = 0;
    int h = fm.getAscent();
    y += h; // add ascent of header font because of baseline
    // positioning (see figure 2.10)
    int nRow, nCol;
    for (nCol=0; nCol<nColumns; nCol++) {
    TableColumn tk = colModel.getColumn(nCol);
    int width = tk.getWidth();
    if (x[nCol] + width > wPage) {
    nColumns = nCol;
    break;
    if (nCol+1<nColumns)
    x[nCol+1] = x[nCol] + width;
    String title = (String)tk.getIdentifier();
    pg.drawString(title, x[nCol], y);
    pg.setFont(m_table.getFont());
    fm = pg.getFontMetrics();
    int header = y;
    h = fm.getHeight();
    int rowH = Math.max((int)(h*1.5), 10);
    int rowPerPage = (hPage-header)/rowH;
    m_maxNumPage = Math.max((int)Math.ceil(m_table.getRowCount()/
    (double)rowPerPage), 1);
    int iniRow = pageIndex*rowPerPage;
    int endRow = Math.min(m_table.getRowCount(),
    iniRow+rowPerPage);
    // take an array to store columns header
    String colNames[] = new String[nColumns];
    for (nCol=0; nCol<nColumns; nCol++) {
    colNames[nCol] = myRs.getColumnName(nCol+1).toString();
    try{
    for (nRow=iniRow; nRow<endRow; nRow++) {
    y += h;
    // set RowSet on the specific row
    myRs.absolute(nRow+1);
    for (nCol=0; nCol<nColumns; nCol++) {
    /* the next 3 lines are old code
    int col = m_table.getColumnModel().getColumn(nCol).getModelIndex();
    Object obj = m_tableModel.getValueAt(nRow, col);
    String str = obj.toString();
    // take the values column by columns
    ImmediateAccess ia = (ImmediateAccess)myRs.getColumnItem(colNames[nCol]);
    String str = ia.getValueAsString();
    if (str.equals("")) str=" ";
    /* this if is usefull if we'd like to have coloring in printing
    if (obj instanceof ColorData)
    pg.setColor(((ColorData)obj).m_color);
    else
    pg.setColor(Color.black);
    pg.drawString(str, x[nCol], y);
    }catch(Exception e){
    e.printStackTrace();
    System.gc();
    return PAGE_EXISTS;
    4- execute printData() method to print.
    e.g. myGridControl.printData();
    let me know if you still cannot print.
    Ali

  • How to print all data in a table?

    Hello!
      I am doing report with VC. Now I want to print data ,The system action "print" can not print all data,only a page in the table  can be printed. Are there any ways to finishe the print function,Can you help me?
    Thank you very much!

    See this how to guide I put together:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/47fe4fef-0d01-0010-6f87-ed8ecb479123

  • How can I print the DATE in the Header/Footer but NOT the TIME?

    I know how use page set-up to change the headers and footers. Firefox doesn't give me the choice of printing just the DATE rather than the DATE/TIME. I tried Custom Date and it printed "Date", and not the date. I tried &Date and it print the Date & Time.
    Is there a way to print just the date?
    Sign me
    Midnight Printer

    You want to print them on their own? Can't be done. WIth the photo? Install this
    http://www.iborderfx.com/iborderfx/

Maybe you are looking for

  • OOS b-channel

    On my syslog I notice this kind of error on E1 b-channel: %CCM_CALLMANAGER-CALLMANAGER 3-BChannelOOS I also notice that: - I have an OOS b-channel from Real Time Monitoring Tool. - if I disconnect the E1 cable from the router and then I connect the c

  • Domain Services for Windows and VMWare View

    We are considering DSfW because VMWare View apparently will only work with Active Directory. Does anyone know if VMWare view will work with DSfW in place of AD? Thanks in advance.

  • App crash when resume

    anyone knows the reason?

  • My MacBook Air freezes when I plug in any usb device or open iPhoto. Please Help?

    I have a MacBook Air that is currently running Mountain Lion OS X (version 10.8.2). Every time that I plug in any type of USB device (trackpad, USB jumpdrive, Time Machine, etc.) my mac freezes and I have to shut it down via the power button. The sam

  • IPhone zurücksetzten.

    Hallo. Ich habe ein iPhone 5 (iOS 7.0.4). Da ich sehr viele Apps und Fotos auf dem iPhone habe, kann ich das nächste Backup nicht installieren (Zu wenig Speicher). Und dieses Backup brauche ich auch um Fotos von meinem Compjuter aufs iPhone zu übertr