Outputting ResultSet into a JTextField

I use this method to execute queries on the database
public ResultSet runQuery(String s) throws java.sql.SQLException
Statement stmt = connection.createStatement();
System.out.println(s);
return stmt.executeQuery(s);
For the query I'm having problems with there is only 1 result in the ResultSet. Can anyone tell me how I get this to output into a JTextField. I think I've tried almost everything!!!

ResultSet rs = runQuery(yoursqlStatement);
Stringbuffer b = new StringBuffer();
while(rs.next){
b.append(rs.getString(1) + "; ");
yourTextField.settext(b.toString());

Similar Messages

  • Reading data from a text file into a JTextField

    So I am writing a program that will write to and read from a large database. I was hoping to allow a graphical interface for the reading of the data, but I keep getting an error;
    Incompatible Types
    Found: java.lang.string
    Required: javax.swing.JTextField
    Now I know that this means the are incompatible (like trying to give an integer variable a string command) but I can't find any documentation on how to change the String into a JTextField format. I've found several references on how to do the reverse, but with my lack of JAVA knowledge I can't seem to get it to work. (Tried things like getText() and the like, but just end up with more errors).
    *On a side note, is there an easier way to go about reading a file line by line, with each line going into a seperate JTextField, than;
    BufferedReader r;
    try {
    r = new BufferedReader(new FileReader("C:\\temp\\test.txt"));
    while ((thisLine = r.readLine()) != null) {
    array[i] = thisLine;
    i = i + 1
    and then assigning each JTextField it's own array slot?*
    Thank you for your help.

    Try something like this for putting the text in a control:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class Junk{
      String[] s = {"This is String 1.", "This is String 2.", "This is String 3."};
      Junk(){
      public void makeIt(){
        JFrame j = new JFrame("Forum Junk");
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel p = new JPanel();
        p.setPreferredSize(new Dimension(300, 200));
        JTextArea jt = new JTextArea();
        p.add(jt);
        j.add(p);
        jt.setText(s[0]);
        jt.append("\n\r"+s[1]);
        jt.append("\n\r"+s[2]);
        j.pack();
        j.setVisible(true);
      public static void main(String[] args) {
        Junk j = new Junk();
        j.makeIt();
    }Depending on your design you may be able to do away with your array and append the text directly to the JTextArray after each line is read.

  • ALV output converted into PDF format and send that PDF to user through mail

    Hi Experts,
    I have report earlier its output was in alv grid.
    Now i want that ALV output converted into PDF format.And that PDF output send to user through mail.
    Can u please tell how to do?
    My code is here(output is displaying in ALV grid).
    INCLUDE <icon>.
    TYPE-POOLS: slis, kkblo.
    TABLES : zmsd_freight_hdr, zmsd_freight_det, zmsd_blinfo, zmsd_diheader.
    TABLES : lfa1.
    DATA : t_hdr   LIKE   zmsd_freight_hdr   OCCURS 0 WITH HEADER LINE,
           T_DET   LIKE   ZMSD_FREIGHT_DET   OCCURS 0 WITH HEADER LINE,
           t_bl    LIKE   zmsd_blinfo        OCCURS 0 WITH HEADER LINE,
           t_di    LIKE   zmsd_diheader      OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF t_det OCCURS 0.
            INCLUDE STRUCTURE zmsd_freight_det.
    DATA    type(30).
    DATA: END OF t_det.
    DATA: v_target2(30),
          v_zsammg LIKE t_det-zsammg,
          v_gsttotal LIKE t_det-zamount.
    DATA : BEGIN OF t_data OCCURS 0,
             zsammg       LIKE  zmsd_freight_hdr-zsammg,
             zdidbl       LIKE  zmsd_freight_hdr-zdidbl,
             zvkorg       LIKE  zmsd_freight_hdr-zvkorg,
             zinvno       LIKE  zmsd_freight_hdr-zinvno,
             zttlamt      LIKE  zmsd_freight_hdr-zttlamt,
             zstatus      LIKE  zmsd_freight_hdr-zstatus,
             ztype        LIKE  zmsd_freight_hdr-ztype,
             zconfirm     LIKE  zmsd_freight_hdr-zconfirm,
             zconfirmdate LIKE  zmsd_freight_hdr-zconfirmdate,
             erdat        LIKE  zmsd_freight_hdr-erdat,
             ernam        LIKE  zmsd_freight_hdr-ernam,
             erzet        LIKE  zmsd_freight_hdr-erzet,
             aedat(10),
             aenam        LIKE  zmsd_freight_hdr-aenam,
             aezet        LIKE  zmsd_freight_hdr-aezet,
             zline        LIKE  zmsd_freight_det-zline,
             zfptype      LIKE  zmsd_freight_det-zfptype,
             zchrcode     LIKE  zmsd_freight_det-zchrcode,
             zcurcode     LIKE  zmsd_freight_det-zcurcode,
             zqty         LIKE  zmsd_freight_det-zqty,
             zuom         LIKE  zmsd_freight_det-zuom,
             zrate        LIKE  zmsd_freight_det-zrate,
             zamount      LIKE  zmsd_freight_det-zamount,
             zexrate      LIKE  zmsd_freight_det-zexrate,
           zccode       LIKE  zmsd_blinfo-zccode,      "MADK991565
             zccode       like  ZMSD_FREIGHT_HDR-zfcode, "MADK991565
             zbldate(10),
             zbl          LIKE  zmsd_blinfo-zbl,
             type(3),
             waerk        LIKE  zmsd_freight_det-zcurcode,
             zamountl     LIKE  zmsd_freight_det-zamount,
           END OF t_data.
    DATA : w_layout      TYPE   slis_layout_alv,
           w_catalog     TYPE   slis_fieldcat_alv,
           t_catalog     TYPE   slis_t_fieldcat_alv,
           w_sort        TYPE   slis_sortinfo_alv,
           t_sort        TYPE   slis_t_sortinfo_alv.
    DATA   V_ZINVNO    like   T_HDR-ZINVNO.                   "MADK991565
    DATA : v_count  TYPE  i.
    SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE text-001.
    PARAMETERS     :  p_zvkorg LIKE zmsd_freight_hdr-zvkorg  OBLIGATORY .
    SELECT-OPTIONS :  s_zdidbl FOR  zmsd_freight_hdr-zdidbl             ,
                      s_zccode FOR  lfa1-lifnr                          ,
                      s_status FOR  zmsd_freight_hdr-zstatus            ,
                      s_ztype  FOR  zmsd_freight_hdr-ztype              ,
                      s_erdat  FOR  zmsd_freight_hdr-erdat              ,
                      s_ernam  FOR  zmsd_freight_hdr-ernam              ,
                      s_zconfd FOR  zmsd_freight_hdr-zconfirmdate       .
    PARAMETERS     :  p_zconf  AS   CHECKBOX                            .
    SELECTION-SCREEN END OF BLOCK a0.
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-002.
    PARAMETERS     :  p_hdr    RADIOBUTTON GROUP rad DEFAULT 'X'        ,
                      p_det    RADIOBUTTON GROUP rad                    .
    SELECTION-SCREEN END OF BLOCK a1.
    INITIALIZATION.
    AT SELECTION-SCREEN.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process.
      PERFORM display.
    END-OF-SELECTION.
      PERFORM fm_get_num_pages.
    AT USER-COMMAND.
    AT LINE-SELECTION.
    TOP-OF-PAGE.
      PERFORM fm_top_of_page USING '7010' sy-title space.
    FORM get_data.
      SELECT   *
        FROM   zmsd_freight_hdr
        INTO   TABLE t_hdr
       WHERE   zvkorg        EQ  p_zvkorg
         AND   zdidbl        IN  s_zdidbl
         AND   zstatus       IN  s_status
         AND   ztype         IN  s_ztype
         AND   erdat         IN  s_erdat
         AND   ernam         IN  s_ernam
         AND   zconfirmdate  IN  s_zconfd
         AND   ZFCODE        IN  S_ZCCODE.                      "MADK991565
      IF p_zconf = 'X'.
        DELETE t_hdr WHERE zconfirm NE 'C'.
      ENDIF.
      CHECK NOT t_hdr[] IS INITIAL.
      SELECT   *
        FROM   zmsd_blinfo
        INTO   TABLE t_bl
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_bl BY zsammg.
      SELECT   *
        FROM   zmsd_diheader
        INTO   TABLE t_di
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_di BY zsammg.
    IF P_DET = 'X'. "MADK933361
      SELECT   *
        FROM   zmsd_freight_det
        INTO   TABLE t_det
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg  =  t_hdr-zsammg
       AND ZINVNO =  T_HDR-ZINVNO .                           "MADK991565
    SORT t_det BY zsammg zline.                            "MADK991565
       SORT T_DET BY ZSAMMG ZINVNO ZLINE.                     "MADK991565
    ENDIF. "MADK933361
    ENDFORM.
    FORM process.
      REFRESH t_data.
      CLEAR v_gsttotal.                                         "MADK933361
      LOOP AT t_hdr.
    Start of MADK933361
        CLEAR: v_target2.
        v_zsammg = t_hdr-zsammg.
        V_ZINVNO = T_HDR-ZINVNO.                                "MADK991565
       AT NEW zsammg.                                         "MADK991565
         AT NEW ZINVNO.                                         "MADK991565
          PERFORM get_gst_value.
        ENDAT.
    End of MADK933361
        PERFORM move_header.
        CHECK t_data-zccode IN s_zccode.
        IF p_det = 'X'.
    CSF Project Changes Starts   DEV34    MADK985782
        LOOP AT T_DET WHERE ZSAMMG = T_HDR-ZSAMMG..
          LOOP AT t_det WHERE zsammg = t_hdr-zsammg AND
                              zinvno = t_hdr-zinvno.
    CSF Project Changes Ends     DEV34    MADK985782
            PERFORM move_header.
            CHECK t_data-zccode IN s_zccode.
            MOVE-CORRESPONDING t_det TO t_data.
            t_data-zamountl = t_data-zamount * t_data-zexrate.
            APPEND t_data.
            CLEAR t_data.
          ENDLOOP.
        ELSE.
          APPEND t_data.
          CLEAR t_data.
        ENDIF.
        AT END OF zsammg.
          CLEAR v_gsttotal.
        ENDAT.
    *Start of changes for  IS090901289-PIA MADK991565
        AT END OF ZINVNO.
          CLEAR V_GSTTOTAL.
        ENDAT.
    *End of changes for  IS090901289-PIA MADK991565
      ENDLOOP.
    ENDFORM.
    FORM move_header.
      MOVE-CORRESPONDING t_hdr TO t_data.
      t_data-zttlamt = t_data-zttlamt + v_gsttotal.             "MADK933361
      t_data-waerk = 'SGD'.
      IF NOT t_hdr-aedat IS INITIAL.
        WRITE: t_hdr-aedat TO t_data-aedat.
      ELSE.
        CLEAR : t_data-aedat.
      ENDIF.
      READ TABLE t_bl WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
      IF sy-subrc EQ 0.
      t_data-zccode  = t_bl-zccode.   "MADK991565
        T_DATA-ZCCODE = T_HDR-ZFCODE.   "MADK991565     
        IF NOT t_bl-zbldate IS INITIAL.
          WRITE: t_bl-zbldate TO t_data-zbldate.
        ENDIF.
        t_data-zbl     = t_bl-zbl.
        t_data-type    = 'DBL'.
      ELSE.
        READ TABLE t_di WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
        IF sy-subrc EQ 0.
        t_data-zccode  = t_di-zdiforcode.     "MADK991565
          T_DATA-ZCCODE = T_HDR-ZFCODE.         "MADK991565
          t_data-type    = 'DI'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM display.
      IF t_data[] IS INITIAL.
        MESSAGE s398(00) WITH 'No Data Selected'.
        EXIT.
      ENDIF.
      DATA : l_repid LIKE sy-repid.
      l_repid = sy-repid.
      REFRESH t_catalog.
      CLEAR   t_catalog.
      w_layout-cell_merge = 'X'.
      PERFORM map_fields.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = l_repid
                i_callback_user_command = 'ALV_USER_COMMAND'
                is_layout               = w_layout
                it_fieldcat             = t_catalog[]
                i_grid_title            = sy-title
                i_save                  = 'A'
                it_sort                 = t_sort[]
           TABLES
                t_outtab                = t_data
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.
    FORM map_fields.
    Sort Order
      CLEAR v_count.
      PERFORM sf USING 'ZDIDBL'   'X'  'X'.
    Fields to be displayed
      CLEAR v_count.
      IF p_hdr = 'X'.
        PERFORM af USING :
       DESCRIPTION       FIELD        LEN   RTABLE             RFIELD
        'DI/DBL         ' 'ZDIDBL'     '14' '                ' '        ',
        'Type           ' 'TYPE'       '04' '                ' '        ',
        'Forwarder Code ' 'ZCCODE'     '14' '                ' '        ',
        'BL Number      ' 'ZBL'        '14' '                ' '        ',
        'BL Date        ' 'ZBLDATE'    '10' '                ' '        ',
        'Invoice Number ' 'ZINVNO'     '15' '                ' '        ',
        'Extraction     ' 'ZSTATUS'    '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type   ' 'ZTYPE'      '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation   ' 'ZCONFIRM'   '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date   ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount   ' 'ZTTLAMT'    '18' '                ' '        ',
        'Created On     ' 'ERDAT'      '10' '                ' '        ',
        'Created By     ' 'ERNAM'      '10' '                ' '        ',
        'Changed On     ' 'AEDAT'      '10' '                ' '        ',
        'Changed By     ' 'AENAM'      '10' '                ' '        '.
      ELSE.
        PERFORM af USING :
       DESCRIPTION         FIELD     LEN   RTABLE             RFIELD
        'DI/DBL           ' 'ZDIDBL'   '14' '                ' '        ',
        'Type             ' 'TYPE'     '04' '                ' '        ',
        'Forwarder Code   ' 'ZCCODE'   '14' '                ' '        ',
        'BL Number        ' 'ZBL'      '14' '                ' '        ',
        'BL Date          ' 'ZBLDATE'  '10' '                ' '        ',
        'Invoice Number   ' 'ZINVNO'   '15' '                ' '        ',
        'Extraction       ' 'ZSTATUS'  '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type     ' 'ZTYPE'    '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation     ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date     ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount     ' 'ZTTLAMT'  '18' '                ' '        ',
        'Freight Payment  ' 'ZFPTYPE'  '14' '                ' '        ',
        'Charge Code      ' 'ZCHRCODE' '10' '                ' '        ',
        'Currency         ' 'ZCURCODE' '08' '                ' '        ',
        'Quantity         ' 'ZQTY'     '13' '                ' '        ',
        'UoM              ' 'ZUOM'     '04' '                ' '        ',
        'Rate             ' 'ZRATE'    '15' '                ' '        ',
        'Amt(Foreign Curr)' 'ZAMOUNT'  '16' '                ' '        ',
        'Exchange Rate    ' 'ZEXRATE'  '13' '                ' '        ',
        'Amt(Local Curr)  ' 'ZAMOUNTL' '16' '                ' '        ',
        'Created On       ' 'ERDAT'    '10' '                ' '        ',
        'Created By       ' 'ERNAM'    '10' '                ' '        ',
        'Changed On       ' 'AEDAT'    '10' '                ' '        ',
        'Changed By       ' 'AENAM'    '10' '                ' '        '.
      ENDIF.
    ENDFORM.
    FORM af USING text
                  field
                  len
                  table
                  reffield.
      v_count = v_count + 1.
      w_catalog-col_pos       = v_count.
      w_catalog-fieldname     = field.
      w_catalog-ref_tabname   = table.
      w_catalog-ref_fieldname = reffield.
      w_catalog-seltext_s     = text.
      w_catalog-seltext_m     = text.
      w_catalog-seltext_l     = text.
      w_catalog-outputlen     = len.
      IF field = 'ZTTLAMT' OR field = 'ZAMOUNTL'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'WAERK'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
    IF FIELD = 'ZRATE' OR FIELD = 'ZAMOUNT'.
      IF field = 'ZAMOUNT'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'ZCURCODE'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
      IF field = 'ZQTY' OR field = 'ZRATE'.
        w_catalog-no_zero     = 'X'.
        w_catalog-datatype  =  'DEC'.
      ENDIF.
      APPEND w_catalog TO t_catalog.
      CLEAR  w_catalog.
    ENDFORM.
    FORM sf    USING   fieldname  sortup  group.
      v_count = v_count + 1.
      CLEAR w_sort.
      w_sort-fieldname = fieldname.
      w_sort-spos      = v_count.
      w_sort-up        = sortup.
      w_sort-group     = group.
      APPEND w_sort TO t_sort.
    ENDFORM.
    FORM alv_user_command USING  in_ucomm    LIKE sy-ucomm
                                 in_selfield TYPE slis_selfield.
      DATA: lfs_data LIKE t_data.
      IF in_ucomm = '&IC1'.
        READ TABLE t_data INDEX in_selfield-tabindex INTO lfs_data.
        CHECK NOT lfs_data-zdidbl IS INITIAL.
        IF lfs_data-type = 'DBL'.
          DATA: l_zdbl LIKE zmsd_diheader-zdinum.
          l_zdbl = in_selfield-value.
          EXPORT l_zdbl TO MEMORY ID 'VBL'.
          CALL TRANSACTION 'ZMSD_BL01'.
        ENDIF.
        IF lfs_data-type = 'DI'.
          DATA: v_dinum LIKE zmsd_diheader-zdinum.
          v_dinum = in_selfield-value.
          EXPORT v_dinum TO MEMORY ID 'VDI'.
          CALL TRANSACTION 'ZMSD_DI01'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM get_gst_value.
      LOOP AT t_det WHERE zsammg = v_zsammg
         AND ZINVNO = V_ZINVNO.                              "MADK991565
        CHECK t_data-zccode IN s_zccode.
        t_det-zamount  = t_det-zamount * t_det-zexrate.
        SELECT SINGLE  y0mmtarget2
                INTO   v_target2
                FROM   y0mmipstranslate
                WHERE  y0mmdatatype = '70' AND
                       y0mmsource = t_det-zchrcode.
        SELECT SINGLE y0mmtarget1
               INTO   t_det-type
               FROM   y0mmipstranslate
               WHERE  y0mmdatatype = '76' AND
                      y0mmsource = v_target2.
        IF t_det-type NE '3Z'.
          v_gsttotal    = v_gsttotal +
                               ( t_det-zamount * 5 / 100 ).
        ENDIF.
      ENDLOOP.
    Regards,
    Raj.

    Hello,
    Following is the procedure to convert alv output to spool and then it to PDF Format.
    After we display the ALV, we can check whether it is running in the background using system field u2018sy-batchu2018. Then,we call an function module named u2018GET_JOB_RUNTIME_INFOu2019 to get the current job information. Then go to spool request table tbtcp to get the spool id.
    Get current job details
      CALL FUNCTION u2018GET_JOB_RUNTIME_INFOu2019
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                               AND jobcount = gd_jobcount
                               AND stepcount = gd_stepcount
                               AND listident <> u20180000000000u2032
                               ORDER BY   jobname
                                                   jobcount
                                                   stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
    Finally, we can call function module u2018CONVERT_ABAPSPOOLJOB_2_PDFu2018 to convert spool reqeust(which is stored in OTF format) to PDF format. Then we can call either function module u2018SO_DOCUMENT_SEND_API1u2032 or SAP BCS (Business Communication Service) to send the pdf as an email attachment.
    CALL FUNCTION u2018CONVERT_ABAPSPOOLJOB_2_PDFu2019
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount = gd_bytecount
           TABLES
                pdf = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
    Regards,
    Sayali
    Edited by: Sayali Paradkar on Apr 20, 2010 12:51 PM

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • How to call a SP with dynamic columns and output results into a .csv file via SSIS

    hi Folks, I have a challenging question here. I've created a SP called dbo.ResultsWithDynamicColumns and take one parameter of CONVERT(DATE,GETDATE()), the uniqueness of this SP is that the result does not have fixed columns as it's based on sales from previous
    days. For example, Previous day, customers have purchased 20 products but today , 30 products have been purchased.
    Right now, on SSMS, I am able to execute this SP when supplying  a parameter.  What I want to achieve here is to automate this process and send the result as a .csv file and SFTP to a server. 
    SFTP part is kinda easy as I can call WinSCP with proper script to handle it.  How to export the result of a dynamic SP to a .CSV file? 
    I've tried
    EXEC xp_cmdshell ' BCP " EXEC xxxx.[dbo].[ResultsWithDynamicColumns ]  @dateFrom = ''2014-01-21''"   queryout  "c:\path\xxxx.dat" -T -c'
    SSMS gives the following error as Error = [Microsoft][SQL Server Native Client 10.0]BCP host-files must contain at least one column
    any ideas?
    thanks
    Hui
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

    Hey Jakub, thanks and I did see the #temp table issue in our 2008R2.  I finally figured it out in a different way... I manage to modify this dynamic SP to output results into
    a physical table. This table will be dropped and recreated everytime when SP gets executed... After that, I used a SSIS pkg to output this table
    to a file destination which is .csv.  
     The downside is that if this table structure ever gets changed, this SSIS pkg will fail or not fully reflecting the whole table. However, this won't happen often
    and I can live with that at this moment. 
    Thanks
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

  • How to  send ALV output data into Excel sheet format via Mail to the user?

    Hi friends,
    I have a doubt ie,
    How to  send ALV output data into Excel sheet format via Mail to the user?
    regards
    Moosa

    Hi,
    Provide the output internal table to the objbin in the below FM
    Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = i_docdata
                put_in_outbox              = c_x
           TABLES
                packing_list               = i_objpack
                object_header              = i_objhead
                contents_bin               = i_objbin
                contents_txt               = i_objtxt
                receivers                  = i_reclist
    and specify the document type
      i_objpack-doc_type   = 'XLS'.
    and try.
    Regards,
    Nandha

  • Outputing results into MS Excel

    Hello all, I am writting an application which gets data from MS Access. Is there a way I can get the results from a query and output them into an Excel spreadsheet??? Thank you

    Hi,
    I agree. Why use excel to read an Access file? They are virtually one and the same thing. But you could implement the AbstractTableModel in java and create your own version of Excel. Much more fun.
    best kev

  • Reg. ALV output transported into Excel

    Dear All,
                   when i transported my ALV report output to excel file , amount column is suppressed from decimal places .
    i.e. in excel file ,  decimal values of amount column is not shown in some amounts.
    Please provide some inputs
    Thanks & Regards
    shailesh

    Hi ,
    Check this [LINK|ALV List output to Excel file; for  ALV output transported into Excel.
    hope it will help you .
    Regards,
    Saravana.S

  • How do I install Adobe Output module into Bridge CC?

    How do I successfully install Adobe Output module into Bridge CC?

    Is this what you are looking for?
    Install Adobe Output Module

  • Can't display the right charachter into a JTextField

    When I try to print the letters consumed by a consumer into the JTextField "consumer1" it just wont do it. Only if I type "return "A" as below.
    I've marked the important places with //---------------->>>>>
    A cut from class Gui
    public static JTextField consumer1;
         public static void addText(String cId) {
              Object a = Consumer.getConsumedItem(cId);
              consumer1.setText(a.toString());
    Class Consumer
    import java.awt.event.ActionEvent;
    import java.util.List;
    import java.util.Vector;
    public class Consumer implements Runnable {
         public Thread consumer = new Thread(this);
         public long DELAY = 0;
         private Buffer buf;
         private String text;
         private CharacterFactory cf;
         private static List<Object> hasConsumedC1 = new Vector<Object>();
         private static List<Object> hasConsumedC2 = new Vector<Object>();
         private static List<Object> hasConsumedC3 = new Vector<Object>();
         private String consumerId;
         public Consumer(String txt, long del, Buffer b, String cId) {
              text  = txt;
              DELAY = del;
              buf = b;
              consumerId = cId;
         public void run ()    {
              while (true) {
                   try {
                        System.out.println("WAITING_ON_BUFFER_ACCESS");
                        if (buf.emptyBuffer())
                             System.out.println("WAITING_ON_BUFFER_NOT_EMPTY");
                        else {     
                             System.out.println("MANIPULATING_BUFFER");
                             System.out.println(buf.take(consumerId));
                             System.out.println("CONSUMING");
                             System.out.println("Tr�den " + this.consumerId + " har f�rdr�jningen " + DELAY + " sekunder");
                             Thread.sleep(DELAY);
                   catch (InterruptedException e) {
    //---------------->>>>>
              Gui.addText("c1");
    //---------------->>>>>
         public void setDelayTime(int i){
              this.DELAY = i*1000;
              System.out.println(DELAY);
         public static void hasConsumed(Object obj, String cId){
              if (cId == "c1")
                   hasConsumedC1.add(obj);
              else if (cId == "c2")
                   hasConsumedC2.add(obj);
              else if (cId == "c3")
                   hasConsumedC3.add(obj);
              public static Object getConsumedItem(String cId) {
    //---------------->>>>>     
         if (cId == "c1")
                   return ("A");
              //return (hasConsumedC1.get(0));     This is what I want it to do!
    //---------------->>>>>     
              else if (cId == "c2")
                   return (hasConsumedC2.get(0));
              else if (cId == "c3") {
              return (hasConsumedC3.get(0));
    From buffer
    public synchronized Object take(String cId){
              while (buffer.isEmpty())
                   try
                        wait(DELAY);
              catch (InterruptedException e){
                   return null;
              Object obj = buffer.get(0);
              buffer.remove(0);
    //---------------->>>>>          
         Consumer.hasConsumed(obj, cId); //Here I put the consumed item into Consumer method hasConsumed
    //---------------->>>>>     ------------------------------------------------------------------------------------------------------------------------------

    Hi,
    Yes now I understand what you want to do, but I think you are doing it in a bad way. What will you do if you have 50 consumers? You should instead do something similar to this (note that it doesn't solve your homework you still have to implement some parts):
    import java.util.Queue;
    import java.util.concurrent.ConcurrentLinkedQueue;
    public class CharacterSoup {
         public static void main(String[] args) throws Exception {
              Queue<Character> queue = new ConcurrentLinkedQueue<Character>();
              Queue<ExecutionReport> reports = new ConcurrentLinkedQueue<ExecutionReport>();
              new Thread(new Consumer("thread1", queue, reports)).start();
              new Thread(new Consumer("thread2", queue, reports)).start();
              for (int i = 'a'; i<= 'z'; i++) {
                   synchronized (queue) {
                        Character ch = Character.valueOf((char)i);
                        System.out.println("Main thread is offering " + ch);
                        queue.offer(ch);
                        queue.notifyAll();
                   Thread.sleep((long)(3000 * Math.random()));
              //TODO create a thread consumes from reports, and populates ui
    class Consumer implements Runnable {
         private String id;
         private Queue<Character> buffer;
         private Queue<ExecutionReport> reports;
         public Consumer(String id, Queue<Character> buffer, Queue<ExecutionReport> reports) {
              this.buffer = buffer;
              this.reports = reports;
              this.id = id;
         public void run() {
              try {
                   Character ch = null;
                   while (true) {
                        synchronized (buffer) {
                             while (buffer.isEmpty()) {
                                  buffer.wait();
                             ch = buffer.poll();
                        synchronized (reports) {
                             System.out.println(id + " added report for " + ch);
                             reports.offer(new ExecutionReport(id, ch));
                             reports.notifyAll();
              } catch (InterruptedException e) {
                   e.printStackTrace();
    class ExecutionReport {
         public String id;
         public Character ch;
         public ExecutionReport(String id, Character ch) {
              this.id = id;
              this.ch = ch;
    }Kaj

  • How to split one modbus serial output port into two?

    Hi all,
    Current Situation 
    My company has a instrument measuring emission in flue gas. The instrument has only one serial port for "modbus" output. The serial port is being used to sending the data collected by the instrument to our DCS.
    My Question
    I have a separate data acquisition computer which is also able to collect data over serial modbus. Is it possible to split the existing serial modbus output port into two so that both the DCS and my data acqusition computer can collect data from the instrument at the same time? If yes, what software and hardware do I need? One more point, high reliability is required for both data collection processes - to the DCS and to the data acquisition computer.
    Thanks and regards,
    Roger 

    What serial protocol are you using? RS-232 or RS-485?
    If it is 485, then it is a multidrop bus, so you can just hook up both receivers to the transmitter via a RS-485 hub. If it uses the 232 protocol, then this would not work as only one device can receive data at any given time, so you could set one node up to repeat the signal to the second hub or use LabVIEW Shared Variables.
    A Quick Comparison of RS-232, RS-422, and RS-485 Serial Communication Interfaces
    Regards,
    Peter Flores
    Applications Engineer

  • Turning a resultset into a JTable

    How can i covert a resultset into a table?
    1. I created a resultset from database data.
    2. I scanned through the resultset to determine how many items i need to extract.
    3. I created an array of the same size as the number of items i need to extract.
    4. Now when i use the getString() commands it tells me that their is no data!
    Help!

    Your ResultSet will not be scrollable so once you've got to the end you can't go back to get the data. You could create a scrollable result set but there's no need if you use another data structure to store your data. You could use a Vector for example and as you will see a JTable has a constructor (Vector v1, Vector v2) where v1 contains the column names and v2 is in fact a Vector of Vectors containing the row data.
    To get the columns names, assuming you have a ResultSet object, rs:
    ResultSetMetaData rsmd = rs.getMetaData();
    Vector columns = new Vector();
    // check these ResultSetMetaData methods in API as I don't have it to hand right now - I think I have them right!
    for (int counter = 0; counter < rsmd.getColumnCount(); ++ counter)
    String name = rsmd.getColumnName(counter);
    v.add(counter);
    }Extract the data from the rows into a Vector of Vectors.

  • Moving a ResultSet into a JTable, cheaply and efficiently.

    Hi,
    This may be something interesting for the more advanced Java programmers.
    I've recently run into an issue, with moving a ResultSet into a JTable. Now, this may seem simple, and believe me it is, but, all the ways I have seen it done, and tried, just don't suite my need.
    DBSql dbsql = new DBSql(); // My database handler class
    tableResults.setModel(new javax.swing.table.DefaultTableModel(dbsql.execute(script), dbsql.getColumns()));
    * Queries the DataBase and populates
    * the values into a two-dimensional object array
    * @param SqlQry
    * @return Object[][]
    public Object[][] execute(String SqlQry) throws SQLException {
    Object[][] obj = null;
    select = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = select.executeQuery(SqlQry);
    rsmd = rs.getMetaData();
    try {
    if (rs.next()) {
    boolean found = true;
    rs.last();
    recordCount = rs.getRow();
    rs.first();
    obj = new Object[recordCount][rsmd.getColumnCount()];
    int i = 0;
    while (found) {
    for (int j = 0; j < rsmd.getColumnCount(); j++) {
    obj[i][j] = rsmd.getColumnType(j + 1) != Constants.TYPE_INTEGER ? rs.getString(j + 1) : rs.getInt(j + 1);
    i++;
    found = rs.next();
    } else {
    recordCount = 0;
    return null;
    } catch(OutOfMemoryError oome) {
    System.gc();
    throw new SQLException("Out Of Memory");
    if(rs != null) rs.close();
    return obj;
    The application I have created is used to connect to any database I want. I have tested it with JavaDB, Microsoft Access, and DB2. The problem is, most DB2's have tables with many records and columns, while most new Relational Databases, have small tables with few records. This code works fantastic with a couple thousand records, with very few columns. But, doesn't cut it when it comes to 50000 records or more. For, instance I queried a DB2 table that has 34000 records and 117 columns ("select * from table"), it doesn't take too long, but it uses way too much memory. If I run that query the application resources 298mb, then when I run it again, it uses a little more and throws an OutOfMemoryError.
    The second issue I have is, I queried another table that has 147000 records and selected 4 columns. No OutOfMemoryError this time - 70mb resourcing - but, the application did take at least 20 minutes to collect those records.
    I have tried using the Vector<Vector<String>> type into the JTable, but, frankly that's just asking for an OutOfMemoryError.
    I have tried creating my own custom table model, with a created data object.
    I have tried inserting rows into a table model in the method itself and returning the table model.
    Eg.
    while (found) {
    Object[] obj = new Object[rsmd.getColumnCount()];
    for (int j = 0; j < rsmd.getColumnCount(); j++) {
    obj[j] = rsmd.getColumnType(j + 1) != Constants.TYPE_INTEGER ? rs.getString(j + 1) : rs.getInt(j + 1);
    tablemodel.insertRow(obj);
    found = rs.next();
    ^I think you can use a vector for this too.
    So far, nothing has solved my problem.
    One thing I have not tried however, is a different table component for this kind of thing.
    I'm basically looking for, a method of doing this, with less overhead and quicker table population.
    Any Ideas?
    Regards,
    That_Gui

    Thanks for the reply.
    "1) Swing related questions should be posted in the Swing forum."
    Apologies, I was caught between swing and essentials, as it seemed to me as, more of a "better ways to do things" kind of question.
    "Also, the approach you are using requires two copies of the data, one in the ResultSet and one in the TableModel."
    I understand that transferring a ResultSet into an Object Array may probably be resource intensive, my delphi colleague made mention of that to me, not too long ago. That is why I'm trying to transfer the ResultSet directly into the table. That is why I used the ListTableModel, which also uses a lot of memory, I have looked at that - I had forgotten to mention that.
    "I have seen approaches where you try to only read a specific number of records. Then as you scroll additional records are read as needed. I can't point you to any specific solution though."
    Using an approach of reading the data as you scroll, sounds great, but also sounds like unnecessary work for the program to do, just like this Object/Vector story. In RPG, if you are working with subfiles (like a JTable), you will display 10 records at a time, and if the user hits the Page Down button you will display the next 10, that is how I'm understanding it.
    "I rarely use DefaultTableModel, creating your own model from AbstractTableModel is a lot more flexible when it comes to how you organise your storage, and it's pretty simple once you get the hang of it."
    This is the dream, I just need to design one that works as I need it.
    "You'd do a select count(*) on your query first to get the total rows expected. Of course one of the problems is that the databased table may change after you've retrieved the length or the items."
    Unfortunately, this is not an option for me, it wont work for what I need.
    I'm going to give the ResultSetTableModel a go - which I think it is actually similar to the ListTableModel - and I will get back to you.

  • How to write records from a resultset into a txt file ???

    Hi, I am a newbie in java servlet technology. Currently, I am having a problem regarding how to write all my records from within a resultset into a text file.
    First, I put all my records into a string variable and then append the string into a stringbuffer. After that, I create a bufferoutputstream and used the write method to write into a text file. Below are the code I used in my program.
    Connection connection = null;
    Statement statement = null;
    ResultSet resultset = null;
    // Connect to database
    connection = getConnection();
    StringBuffer str_buf = new StringBuffer();
    statement = connection.createStatement();
    resultset = statement.executeQuery("SELECT * FROM STUDENT");
    String data_row = "";
    str_buf.append("STUDENT_ID,NAME,PHONE,ADDRESS,RESULT");
    while (resultset.next()) {
       data_row = "\n";
       data_row += resultset.getLong("STUDENT_ID");
       data_row += ",\"" + resultset.getString("NAME").trim() + "\"";
       data_row += ",\"" + resultset.getString("PHONE").trim() + "\"";
       data_row += ",\"" + resultset.getString("ADDRESS").trim() + "\"";
       data_row += ",\"" + resultset.getString("RESULT").trim() + "\"";
       str_buf.append(data_row);
    BufferedOutputStream buf_out = null;
    // Create a folder and write all records into info.txt
    String fileName = "student/info.txt";
    buf_out = new BufferedOutputStream(new FileOutputStream(fileName));
    int str_len     = str_buf.length();
    for (int i = 0; i < str_len; i++) {
       buf_out.write(str_buf.charAt(i));
    }So. is this a proper way to write information into a text file ?
    The total records are around 150 000. Now, I get an exception which is "XServletError : System.lang.outofmemory". It happen if the total records are more than 60 000, within a while loop when I try to append a string into a stringbuffer.
    How should I deal with this kind of situation?
    Thanks in advanced and any advice is appreciated. Example is even better to improve understanding.
    Thanks

    Connection connection = null;
    Statement statement = null;
    ResultSet resultset = null;
    // Connect to database
    connection = getConnection();
    StringBuffer str_buf = new StringBuffer();
    String fileName = "student/info.txt";
    FileWriter fw = new FileWriter(fileName);
    statement = connection.createStatement();
    resultset = statement.executeQuery("SELECT * FROM
    STUDENT");
    String data_row = "";
    fw.write("STUDENT_ID,NAME,PHONE,ADDRESS,RESULT");
    while (resultset.next()) {
    data_row = "\n";
    data_row += resultset.getLong("STUDENT_ID");
    data_row += ",\"" + resultset.getString("NAME").trim()
    + "\"";
    data_row += ",\"" +
    resultset.getString("PHONE").trim() + "\"";
    data_row += ",\"" +
    resultset.getString("ADDRESS").trim() + "\"";
    data_row += ",\"" +
    resultset.getString("RESULT").trim() + "\"";
    fw.write(data_row);
    fw.close();

  • How to write the resultset into a text file

    how to write the resultset into a text file

    You can use the java.io.* package to write to files.
    API: http://java.sun.com/j2se/1.5.0/docs/api/java/io/package-summary.html
    Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/index.html

Maybe you are looking for

  • I upgraded the ram all on my own...

    i'm happy to report that my MacMini G4 is now sporting a brand new 1 Gig RAM stick and is zipping along beautifully. i should say however that had i known what the experience would be like (having completed an upgrade on my own), i would probably not

  • How to view sub folders on Apple TV

    I have Home Sharing turned on.  I have a folder on my server that has my videos.  I have sub folders in this make folder, such as Home Movies -> Kid 1 or Home Movies -> Kid 2. When viewing these video files on my Apple TV's I see the content in the M

  • Video Out Mod?

    I know this is crazy, but I have a nagging curiosity about this: I have the 300 MHz Blueberry iBook. I know there is no video out on these things. But I know that there is a 20-pin display data connector inside. Is it theoretically possible to splice

  • Not Allow to Insert

    Hi : In My application there is table called baseline_effort where it contains Projects and Objects what i need is If project and object is already in the database if i try to reenter the same project it must show some message saying database already

  • Where to buy Snow Leopard Server? OEM okay?

    All, I have half a dozen XServe (late 2008 machines) to upgrade from Leopard Server to Snow Leopard Server. I have been investigating how to go about doing this and have a couple of questions: 1) does Apple still sell this software? If so, how the he