How to read and store data from an SQL resultset

I'm writing a program to create testing scripts. I have a working version of the program that takes data from a specific input file, processes it and then outputs it as a test file that is readable by this other system. That's all fine and dandy, but now I wish to extend my program so that it doesn't need the input file, it shoud run an SQL query on the database itself and output this, with some other data to the output file, I have been experimenting with some code below:
          ResultSet rset;
          rset = sql.sqlweight();
          while (rset.next()!= false)
               System.out.println("I'm getting to this loop");
               scanCode = rset.getString(1);
               System.out.println(scanCode);
               rset.next();
          }And method sqlweight looks like this:
     public static ResultSet sqlweight() throws SQLException
          Connection connectiona = DriverManager.getConnection(//hiding connection details);
          Statement stmtW = connectiona.createStatement();
          String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
          ResultSet rset = stmtW.executeQuery(sqlW);
          while (rset.next())
               //System.out.println(rset.getString(1));
          //rset.close();
          //stmtW.close();
          //connectiona.close();
          return rset;
     }Code is a bit messy at the moment as I am constantly changing and adding things so excuse the formatting. I can't get it to enter the loop (hence the testing line I put in it). I am wondering what the best way would be to get the data held in the results set into my String variable scanCode. Thanks for any help or advice.

I haven't thrown it away, it just looks like this now:
     public static ResultSet sqlweight() throws SQLException
          Connection connectiona = DriverManager.getConnection(//hiding connection details);
          Statement stmtW = connectiona.createStatement();
          String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
          ResultSet rset = stmtW.executeQuery(sqlW);
          return rset;     
     }

Similar Messages

  • How to read and write data from json file from windows phone7 app

    Hi
    I am developing wp7 app for the use of students my questions are
    How can i write a code to read and write the json/text file for the wp7.
    I am using windows 7 OS, VS 2010 Edition.
    This is my code below:
    xaml:
    <Grid>
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="7,18,0,550" Name="textBlock1" Text="Full
    Name: " />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,1,0,0" Name="txtName"
    Text="Enter your full name" VerticalAlignment="Top" />
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="6,75,0,0" Name="textBlock2" Text="Contact
    No: " VerticalAlignment="Top" />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,61,0,480" Name="txtContact"
    Text="Enter your contact number" MaxLength="10" />
                        <Button Content="Register" Height="72" HorizontalAlignment="Left" Margin="10,330,0,0" Name="btnRegister"
    VerticalAlignment="Top" Width="190" Click="btnRegister_Click" />
                    </Grid>
    xaml.cs:
    private void btnRegister_Click(object sender, RoutedEventArgs e)
                string name, contact;
                name = txtName.Text;
                contact = txtContact.Text;
                try
                    if (name != "" && contact != "")
                        string msg = name + " " + contact;
                        MessageBox.Show(msg);
                        Student stud = new Student
                            Name= name,
                            Contact = contact,
                        string jsonString = JsonConvert.SerializeObject(stud);
                        MessageBox.Show(jsonString);
                    else
                        MessageBox.Show("Input Proper Information", MessageBoxButton.OK);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
    I have download NewtonSoft.json version 5.0.8.
    So, I am able to convert input data into json format, but how can I able to write and read this data from a json/text file.
    How can I do?
    Thank you in adv and please, reply soon.

    We don't have many samples left for Windows Phone 7 + Azure, the closest one to what you want to do is probably:
    Using Local Storage with OData on Windows Phone To Reduce Network Bandwidth
    this sample uses the local database feature: 'LINQ to SQL', available to Windows Phone 7.1 and 8.0 Silverlight applications, instead of simple file storage but even if you choose to stick with simple file storage I believe you should be able to adapt the
    networking related portions of the sample to your particular application.
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • How to read and write data from Excel to TestStand without using LabVIEW VIs

    Hi,
    How can I read in columns of data from Excel into a TestStand array and write columns of data to Excel from TestStand without using LabVIEW VIs?
    I don't think the Property Loader custom step type in TestStand will work because the data I would like to read in from Excel is in a column that is thousands of rows long and the data has to be in the proper format to use the Property Loader to load in an array from Excel.
    Thanks for your help.

    That example does not use LabVIEW and it does about 40% of what you need to do by calling Excel through ActiveX. If you don't know how to use Excel through ActiveX then you'll need to brush up on that.
    http://www.microsoft.com/en-us/download/details.aspx?id=16250
    http://support.microsoft.com/kb/141759
    http://support.microsoft.com/kb/302084
    CTA, CLA, MTFBWY

  • Creating a external content type for Read and Update data from two tables in sqlserver using sharepoint designer

    Hi
    how to create a external content type for  Read and Update data from two tables in  sqlserver using sharepoint designer 2010
    i created a bcs service using centraladministration site
    i have two tables in sqlserver
    1)Employee
    -empno
    -firstname
    -lastname
    2)EmpDepartment
    -empno
    -deptno
    -location
    i want to just create a list to display employee details from two tables
    empid firstname deptno location
    and same time update  in two tables
    adil

    When I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list.  When I attempt to edit it, I get an error:
    External List fails when attached to a SQL view        
    Sorry, something went wrong
    Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
    I can edit the view in SQL Manager, so it seems strange that it fails.
    Any advice would be greatly GREATLY appreciated. 
    Thanks,
    Randy

  • How to read and write data in to a specified range of cells(it include multiple row & columns) in excel

    How to read and write data in to a specified range of cells(it include multiple row & columns) in excel

    CVI Comes with a sample project that explains how to read/write to a Excel file: choose "Explore examples..." in CVI welcome page and navigate to <cviSampleDir>\activex\excel folder where you can load excel2000dem.prj.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • JSP read and write data in MS-SQL database

    I am new to JSP. I need to write JSP page to read and write data in MS-SQL Database. I wonder if it is different from other database. I couldn't find useful pointers in the web. Please advise. Thanks!!

    Sure, SQL Server is different from Oracle is different from MySQL is different from...
    But all of them can be accessed using JDBC:
    http://java.sun.com/docs/books/tutorial/jdbc/
    Maybe you should learn about that for starters.
    You can use SQL tags from JSTL in your JSPs. I'd recommend JSTL highly. No scriptlet code that way. - MOD

  • Read and write data from content repository .

    Hi All,
    We are using content repository to store some document and images on web center server .
    So we have created/setup a content repository on web center .
    Please proivde me some documnet /wiki page to get some idea how can i read and write date in
    content repository .
    You are most welocme to provide some idea /suggestion .
    Thanks,
    Arun.

    Have you already configured webcenter spaces so it can use content server?
    Have you installed the content server seperatly from webcenter or as a part of the webcenter installation?
    Check if you have the webcenter spaces component installed in content server because without i don't think it will work...
    If you already have configured UCM to work with spaces it's quiet easy.
    From your groupspace, open the settings page of your groupspace. Go to the services tab. In the left hand side you can enable the documents services. WHen you have done that, you are able to add the document services taskflows to your pages. Just go to a page in your pagegroup and edit it. Open the resource catalog and you will find some extra taskflows you can add.
    If you haven't configured UCM and webcenter to work together, here some steps that will help you:
    * Integrating UCM with Spaces
         * They both need to use the same LDAP store.
         * Since there is no LDAP server available, we choose for embedded WLS LDAP.
         * Integrating the ucm into apache
              * Stop UCM
              * In /oracle/product/wls10320/WebCenter/ucm/config/config.cfg, check the SocketHostAddressSecurityFilter to contain 127.0.0.1
              * Add the SocketHostAddressSecurityFilter to /oracle/product/wls10320/WebCenter/ucm/admin/bin/intradoc.cfg
              * Add to /oracle/product/wls10320/WebTier/instances/instance1/config/OHS/ohs1/httpd.conf
                   include /oracle/product/wls10320/WebCenter/ucm/data/users/apache22/apache.conf
              * Change the mod_wl_ohs.conf file to
                   <IfModule weblogic_module>
                         WebLogicHost localhost
                         WebLogicPort 7001
                         Debug ON
                         WLLogFile /tmp/weblogic.log
                   </IfModule>
                   <Location /webcenter>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8888
                   </Location>
                   <Location /webcenterhelp>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8888
                   </Location>
                   <Location /owc_discussions>
                      SetHandler weblogic-handler
                      WebLogicCluster localhost:8890
                   </Location>
                   <Location /em>
                      SetHandler weblogic-handler
                   </Location>
                   <Location /console>
                      SetHandler weblogic-handler
                   </Location>
                   <Location /consolehelp>
                      SetHandler weblogic-handler
                   </Location>
              * Restart UCM & WebTier
              * Test URL: http://yourServer:7777/idc
         * Configure the Identity Store for UCM & WebCenter
              * Set the password for the embedded ldap in WLS
                   Console => Domain Name => Security tab => Embedded LDAP tab => reset credentials
              * Restart AdminServer
              * Stop UCM
              * Add the following to /oracle/product/wls10320/WebCenter/ucm/config/jps-config.xml
                      <serviceInstance name="idstore.oid" provider="idstore.ldap.provider">
                          <property name="subscriber.name" value="ou=myrealm,dc=webcenter_domain"/>
                          <property name="idstore.type" value="WLS_OVD"/>
                          <property name="security.principal.key" value="ldap.credential"/>
                          <property name="security.principal.alias" value="JPS"/>
                              <property name="ldap.url" value="ldap://yourServer:7001"/>
                          <extendedProperty>
                              <name>user.search.bases</name>
                              <values><value>ou=people,ou=myrealm,dc=webcenter_domain</value></values>
                          </extendedProperty>
                          <extendedProperty>
                              <name>group.search.bases</name>
                              <values><value>ou=groups,ou=myrealm,dc=webcenter_domain</value></values>
                          </extendedProperty>
                          <property name="username.attr" value="uid"/>
                          <property name="user.login.attr" value="uid"/>
                          <property name="groupname.attr" value="cn"/>
                      </serviceInstance>
              * In the same file, change the serviceInstanceRef ref="idstore.ldap" to "idstore.oid"
              * Go to /oracle/product/wls10320/WebCenter/ucm/custom/FustionLibraries/tools
              * ./run_credtool.sh
                   Alias: default
                   Key: default
                   User Name: cn=Admin
                   Password: weblogic123
                   JPS Config: default
              * Start UCM
              * Check Provider:
                   * Go to http://yourServer:7777/idc
                   * Login : sysadmin/idc
                   * Administration -> Providers
                   * jpsuser should be good
                   * When a ldapuser exist, disable it!!
         * Configuring UCM for content search
              * Change the file /products/WebCenter11gR1/WebCenter/ucm/config/config.cfg
                  SearchIndexerEngineName=DATABASE.METADATA to SearchIndexerEngineName=DATABASE.FULLTEXT
              * Restart UCM server
              * Run the /products/WebCenter11gR1/WebCenter/ucm/database/oracle/admin/batchsnippet.sql in the wcbepsc_ocserver schema
              * Restart UCM server
              * Open the /products/WebCenter11gR1/WebCenter/ucm/bin/RepositoryManager (sysadmin/idc)
              * Recreate the indexes
         * Registering UCM with WebCenter
              * Go to http://yourServer:7777/em
              * Login with weblogic/weblogicPassword
              * Go to WebCenter - WebCenter Spaces - webcenter (WLS_Spaces)
              * From the top menu, select Settings - Service Configuration     
              * Select Content Repository
              * Add
                   Connection Name: ucm_connection
                   Repository Type: Oracle Content Server
                   Active Connection: checked
                   Administrator User Name: sysadmin
                   Root Folder: /WebCenterSpaces
                   Application Name: Spaces
                   CIS Socket Type: Socket
                   Server Host: localhost
                   Server Port: 4444
                   Authentication Method: Identity Propagation
              * Restart WLS_Spaces
         * Test the connection by creating a new group space and upload a document to the document page of this group spaceHope this helps.

  • How to read a byte data from maxdb data base

    Dear All,
    I have a issue in reading the data from database table.
    I have a column named as templateData which contains the byte data (biometric template data, which comes from fingerprint device) which is DataType of LONG and CODE of BYTE.
    I am not using the below to get the template data
    Connection con = null;
      Statement stmt = null;
      ResultSet resultSet = null;
    byte[] DbBioData = new byte[1024];
    InitialContext ctx = new InitialContext();
       if(ctx == null)
         throw new Exception("Boom - No Context");
       DataSource ds = (DataSource)ctx.lookup(db_drvstr);
       con = ds.getConnection();
       stmt = con.createStatement();
       resultSet  = stmt.executeQuery(db_query + " where SUBJECT_ID='"+ username +"'");
       if(resultSet.next())
        DbBioData = resultSet.getBytes(1);
        _loc.infoT("verify", "verify::Got BioData From MAXDB" +DbBioData );
        loc.infoT("verify", "verify::Query is: " +dbquery + " where SUBJECT_ID='"+ username +"'" );
    But I am not getting the proper data, could anyone please tell me the way to read the biometric data from data base table.

    Hi Kishore,
    is it me or is there no query definition in that code?
    I see that you concatenate a "db_query" with a string to make up a WHERE clause, but the db_query is nowhere defined before.
    So at least you should provide something like
    stmt = con.createStatement("SELECT templateDate FROM <tablename> ");
    before you do anything with the query.
    Besides this: have you ever heard of SQL injections? Try to use BIND-variables instead of concatenating strings. Otherwise your application will spend much time just with parsing your queries...
    Hmm... possibly the best thing you could do about this is to read the JAVA manual for MaxDB:
    <a href="http://maxdb.sap.com/currentdoc/ef/2de883d47a3840ac4ebb0b65a599e5/content.htm">Java Manual (SAP Library - Interfaces)</a>
    Best regards,
    Lars
    Edited by: Lars Breddemann on Dec 17, 2007 1:12 PM - corrected link

  • Read and Get Data from PDF

    Hi All,
    I am fairly new to programming macros in Excel VBA, and right now I need to write a macro that can open a PDF file and read it and get data from there and paste it into an excel spread sheet. Is this possible?  If so can you give me some sample code
    that would do that?

    I did this once many years ago.  I had to have Acrobat Professional installed ($$$).  There are free pdf parsers that you access from VBA using Win32 commands like:
    https://code.google.com/p/peepdf/
    Maybe something has changed since I did it

  • Read and write data from virtual port (bluetooth adaptor)

    Hi,
    I want to read and wirte data to the bluetooth adaptor by java. I connected my bluetooth adapter to COM3.(virtual port). Anybody help me with this.I need very urgent.
    Thanks,
    with regards,
    thelay

    Deepa_05 wrote:
    Hi,
    I didn't get jar fileAnd?

  • How to read LONG RAW data from one  table and insert into another table

    Hello EVERYBODY
    I have a table called sound with the following attributes. in the music attribute i have stored some messages in the different language like hindi, english etc. i want to concatinate all hindi messages and store in the another table with only one attribute of type LONG RAW.and this attribute is attached with the sound item.
    when i click the play button of sound item the all the messages recorded in hindi will play one by one automatically. for that i'm doing the following.
    i have written the following when button pressed trigger which will concatinate all the messages of any selected language from the sound table, and store in another table called temp.
    and then sound will be played from the temp table.
    declare
         tmp sound.music%type;
         temp1 sound.music%type;
         item_id ITEM;
    cursor c1
    is select music
    from sound
    where lang=:LIST10;
    begin
         open c1;
         loop
              fetch c1 into tmp; //THIS LINE GENERATES THE ERROR
              temp1:=temp1||tmp;
              exit when c1%notfound;
         end loop;
    CLOSE C1;
    insert into temp values(temp1);
    item_id:=Find_Item('Music');
    go_item('music');
    play_sound(item_id);
    end;
    but when i'm clicking the button it generates the following error.
    WHEN-BUTTON-PRESSED TRIGGER RAISED UNHANDLED EXCEPTION ORA-06502.
    ORA-06502: PL/SQL: numeric or value error
    SQL> desc sound;
    Name Null? Type
    SL_NO NUMBER(2)
    MUSIC LONG RAW
    LANG CHAR(10)
    IF MY PROCESS TO SOLVE THE ABOVE PROBLEM IS OK THEN PLESE TELL ME THE SOLUTION FOR THE ERROR. OTHER WISE PLEASE SUGGEST ME,IF ANY OTHER WAY IS THERE TO SOLVE THE ABOVE PROBLEM.
    THANKS IN ADVANCE.
    D. Prasad

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • How can read and process data uploded from a datalogger on a network with labview

    hello evryone.
    i have a agilent datalogger 34972a data acquire temperature reading and makes them availlable on a network. i would like to acess this data on a pc running labview, analyse and prsent them. my problem is that i am not quite sure how to tell labview acquire this specific data.
    any help would really help me getting started.
    thanks already.
    Yann

    Are you
    Running the Agilent stand alone (or using Benchlink) and writing data to a file on the network ?
    Do you want to use LabView to control the networked data logger and aquire data? 
    If you are doing #1 then you can not use LabView because the Agilent (and Benchlink) strores data in a proparitary format.
    You have to use Benchlink to export the data to a CSV file before any other program besides Benchlink can read it.
    If you want to do #2 then you simply access the Agilent through VISA just like if it were connected using USB, Serial, or GPIB. 

  • Read and write data from / to cube in CUSTOM_LOGIC BADI

    Here are the details:
    BPC displays a set of details - with 5 rows and 5 columns. There are 50 additional rows for the 5 columns which are blank to start with.
    User changes a cell. BPC 10 only sends that cell which is changed by the user in CUSTOM_LOGIC and WRITE_BACK BADIs.
    I need to get other 5 X 5 cells (other than 1 cell, which is changed and being passed in the BADIs) details to determine all the details and calculate the additional 50 rows. After calculating these values, i need to update the cube so that the BPC report refreshes with the data i have updated.
    Whats the best way? What are the funtion modules involved in reading / writing? Are there any best practices to read / write data from cube.
    Appreciate your help.

    Hi Ravan,
    Look at my sample write back badi here: http://scn.sap.com/message/14290977#14290977
    At the end of the code I have values updated in ct_data. The contents of ct_data will be automatically written to the cube (you don't need to have special code to write data).
    B.R. Vadim

  • Regarding ABAP program to read and manipulate data from Excel file....

    Hi,
    I want to write a ABAP program which will read Excel file which has three columns viz: Col A, Col B and Col C.
    If there is no data in Col B and Col C for a given record in Column A, then progam should print all those records on screen with write statement.
    Regards,
    Rajesh.

    Hi
    Check
    PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
    begcol TYPE i DEFAULT 1 NO-DISPLAY,
    begrow TYPE i DEFAULT 1 NO-DISPLAY,
    endcol TYPE i DEFAULT 100 NO-DISPLAY,
    endrow TYPE i DEFAULT 32000 NO-DISPLAY.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    filename = filename
    i_begin_col = begcol
    i_begin_row = begrow
    i_end_col = endcol
    i_end_row = endrow
    TABLES
    intern = intern
    EXCEPTIONS
    inconsistent_parameters = 1
    upload_ole = 2
    OTHERS = 3.
    After getting Records in INTERN TABLE  You can loop it to check where columns B & C are empty  and store them in another table .
    LOOP AT intern.
    IF INTERN  B and C has value  .
    CONTINUE
    ELSE .
    MOVE THEM INTO ANOTHER TABLE ITAB .
    ENDIF .
    ENDLOOP.
    THEN LOOP ITAB .
    WRITE : ' '
    ENDLOP .
    Hope this Helps .
    Praveen

  • How to read the hierarchy data from the same table using loop in AMDP method

    Hi All,
    We have a requirement to get the top partner from BUT050 table.
    Here the Top parent is nothing but the top most in the hierarchy of the partners from BUT050.
    Example:
    For partner 1234 (BUT050-PARTNER1) there is partner 3523(BUT050-PARTNER2) one level above
    For partner 3523(BUT050-PARTNER1)  there is partner 4544 (BUT050-PARTNER2) last level .
    so in this case for the partner 1234 the Top parent is 4544 .
    I have created AMDP Procedure method to get the top-parnet and below given is the logic implemented in AMDP method.
    Here i have implemented a recursive logic with the WHILE loop to get the top most hierarchy partner from the same table BUT050
    IV_Parent is the input partner and ev_top_parent is the output value.
    AMDP Procedure Method:
        DECLARE lv_date VARCHAR(8) := TO_VARCHAR (current_date, 'YYYYMMDD');
        DECLARE found INT := 1;
              iv_partner1 =  SELECT partner1 FROM but050
                              WHERE partner2 = iv_partner
                              AND reltyp = :iv_hierarchy
                              AND date_to >=  :lv_date
                              AND date_from <= :lv_date;
         WHILE found <> 0  do
           select partner1 into ev_top_parent from :iv_partner1;
                           iv_partner1 =  SELECT partner1 FROM but050
                           WHERE partner2 in ( select partner1 from :iv_partner1 where partner1 is not null)
                           AND reltyp = 'ZBP004'
                           AND date_to >= :lv_date
                           AND date_from <= :lv_date;
           select COUNT ( partner1 ) INTO found FROM :IV_PARTNER1;
        END WHILE;
    This method is working fine, but here it is only taking one single partner and getting the top parent as output.
    Now i would like to convert this mehtod so as to accept n number of partners (not one single partner) as input and should process each partner to get the top parent.
    Could anyone guide me how can i handle the given AMDP method further so as to work some how it is within another loop from other AMDP method.
    Thanks.
    Regards,
    Laxman.P

    Hi
    Go to SE11 and enter the hierarchy table name.
    /BIC/H....(infoobject name)...and execute the table and select table entry and delete all....
    Thanks
    TG

Maybe you are looking for

  • Posting of Exchange rate differences in parallel currencies

    Hello experts,, We are on ECC 6. When we enter an incoming invoice with MIRO and the current exchange rate differs from that in the PO, the exchange rate differences in local currency and in parallel currency (group currency) post to different accoun

  • JDBC Driver: MS Access

    I need to connect locally to a mdb file on a Windows OS and manipulate its data. I have tried the sun.jdbc.odbc.JdbcOdbcDriver but it does not support primary keys manipulation. I have read numerous topics about JDBC drivers for MS Access, some of th

  • Documentation Tool for Essbase Applications

    Are your Essbase applications adequately documented? Are you interested in a tool that facilitates documenting Essbase models? Faced with the Herculean task of documenting a very complex planning model for a recent customer, I developed this great to

  • Bonus depreciation valid till 2010

    Hi gurus, I am still learning AA. I got business requirement to make bonus depreciation valid till 2010 where right now it is valid till Jan 2009. Please advise steps that need to be done to extend the bonus depreciation. <Please do not solicit point

  • Rev A or Rev B

    Hey guys, I notice that there are many problems posted on this forum, and could possibly turn away potential switchers and/or buyers. Anyway, I was just wondering if we could make a standard with posting, that you post what revision your computer is,