RecordSet vs ResultSet

I'm used to manage recordset ( ado ) ... I'm a bit lost with resultset...
There is no "State" .BOF .EOF ...
Question/Problem:
How can I know if a recordset is null or empty?
Request:
PS: is there is any link, articles, document which are comparing recordset and resultset function ( comparable function ( equivalence ) )
Thanks you

Question/Problem:
How can I know if a recordset is null or empty?In general, you have to call next() until it returns false. A ResultSet does not necessarily contain all the rows queried. JDBC may make multiple calls to the database for large queries, so even knowing a ResultSet's size (which you can't do anyways) wouldn't necessarily give you the query size.
Request:
PS: is there is any link, articles, document which are
comparing recordset and resultset function (
comparable function ( equivalence ) )Don't know of any on that specifically, but for JDBC info, check out the tutorial: http://java.sun.com/docs/books/tutorial/jdbc/index.html
There are also some technical articles here: http://developer.java.sun.com/developer/technicalArticles/Database/

Similar Messages

  • RecordSet and ResultSet

    When Should I use RecordSet and when ResultSet?

    But how does importing an entire package makeany
    difference to which class you actually use?Am I missing something? In what package isRecordSet?
    No idea. I'm just curious why importing an entire
    package would help make this decision. Hadn't even
    considered where RecordSet comes from. It's not part
    of the JDK, AFAIKI don't think that the poster wanted you to read it as an import but rather as "you should use the classes within the java.sql package when you can".

  • How to fetch records with two recordset

    i want fetch records from the table using two recordset like
    ResultSet r1=stmt.executeQuery("select * from pf_data");
    i want to take another recodeset
    ResultSet r2=stmt.executeQuery("select * from finyr");
    I am using Microsoft SQL server as my database.
    I am also closing the recordset like r1.close();
    then i cannot take two recordset at the same time.

    Hi,
    This is an example of a Top-N problem, and here's one way to do it:
    WITH got_r_num AS
        SELECT  item_id, supp_id, rnk                         -- RANK is not a good column name
        ,       DENSE_RANK () OVER ( PARTITION BY  item_id    -- Just guessing
                                     ORDER BY      rnk
                                   )  AS r_num
        FROM    table_x
        WHERE   item_id  = 2      -- If desired
    SELECT    item_id, supp_id. rnk
    FROM      got_r_num
    WHERE     r_num    <= 2
    RANK is the name of a built-in function in Oracle, so it will cause lots of trouble if you use it as a column name.  (The RANK function is closely related to DENSE_RANK, used above.)
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places.  If you changed the query at all, post your code.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Retrieiving hashmap which contains database tables in it

    Hi,
    I am new to java and i am struggling on this issue.
    I have an xml file which has readers and publishers.
    I am writing some queries in each reader and trying publish that in publisher class.
    I have recordset for each query in publisher as property. as shown below
    My problem is i am writing a generic publisher class where i have to take all recordsets or resultsets from xml file and display there count, and if count>0 then display one of the columns like all ID's.
    As I told, this has to be generic class, even if I add any more readers with queries to my xml file my publisher class has to be same.
    I am sending hashmap as parameter to the publish class method, which has all the result sets and their data.
    any kind of help is appreciated.
    Thanks

    any kind of help is appreciated.help with what?
    what is the problem?
    not a very good first post i'd say

  • Unsupported response content type soap error

    I have created a java method that returns an array of a class type (my class is an EJB). Then created a web service using Apache soap as deployment platform (see my previous posting for details). Created client stub and client application to access the method and display the result on the screen. When running the client application I get the 'unsupported response content type' error.
    Can anyone help please, I am desparate!!!
    Thanks
    Alina

    I have created the following EJB class and another class that has got the web method:
    package orbatlistarraypackage;
    import java.util.Date;
    import java.io.Serializable;
    public class OrbatType implements java.io.Serializable
    public String orbatName;
    public int orbatID;
    public OrbatType()
    public void setOrbatName(String pName)
    orbatName = pName;
    public String getOrbatName()
    return orbatName;
    public void setOrbatID(int pID)
    orbatID = pID;
    public int getOrbatID()
    return orbatID;
    I have another class that is an array of the OrbatType class and has a webmethod that returns the array.
    package orbatlistarraypackage;
    import java.sql.*;
    public class OrbatListArray
    OrbatType [] orbatList;
    public OrbatListArray()
    private void setOrbatArray() throws Exception
    Connection cn = GetOrbatConnection.getConnection();
    Statement st = cn.createStatement();
    ResultSet rs = st.executeQuery("SELECT DESCRIPTION as ORBATNAME, ID AS ORBATID FROM ORBATS");
    //to get number of records to determine array size
    int noOfRecords;
    noOfRecords = 0;
    while(rs.next())
    noOfRecords = noOfRecords + 1;
    //new recordset as rs is once only forward reading recordset.
    ResultSet rsOrbat = st.executeQuery("SELECT DESCRIPTION as ORBATNAME, ID AS ORBATID FROM ORBATS");
    orbatList = new OrbatType[noOfRecords];
    int i;
    i = 0;
    while(rsOrbat.next())
    orbatList[i] = new OrbatType();
    orbatList.SetOrbatName(rsOrbat.getString("ORBATNAME"));
    orbatList[i].SetOrbatID(rsOrbat.getInt("ORBATID"));
    i = i + 1;
    rs.close();
    rsOrbat.close();
    @webmethod
    public OrbatType [] getOrbatListArray() throws Exception
    SetOrbatArray();
    for(int i=0;i<orbatList.length;i++)
    System.out.println(orbatList[i].GetOrbatName());
    System.out.println(orbatList[i].GetOrbatID());
    return orbatList;
    //dummy to just generate the web service
    //public int foo() {return 0;}
    /*this works
    public static void main(String arg[]) throws Exception
    OrbatListArray myArray = new OrbatListArray();
    myArray.GetOrbatListArray();
    Does this answer your question? If so can you help please?
    Thanks
    Alina

  • Proxy to CSV format

    Hi
    I have a scenario proxy to CSV format. What are the content conversion parameters i have to use on receiver side for CSV format.
    venkat

    Hi Venkat !!
    Basically, you should use a communication channel with File Adapter, type receiver, message protocol = File Content Conversion.
    Take this XML structure for example:
    <resultset>
    <row>
    <column-name1>column-value</column-name1>
    <column-name2>column-value</column-name2>
    <column-name3>column-value</column-name3>
    </row>
    <row>
    <column-name1>column-value</column-name1>
    <column-name2>column-value</column-name2>
    <column-name3>column-value</column-name3>
    </row>
    </resultset>
    In content conversion parameters, to obtain a CSV format file, you should enter:
    Recordset Structure: "resultset"  (without quotes)
    In the below table:
    name: resultset.fieldSeparator   -
    > this sets the field separator
    value: ','   ---> as comma
    name: resultset.endSeparator  -
    > this sets the line separator
    value: 'nl'   -
    > as new line
    Regards,
    Matias.

  • Assign and OO4O resultset to an ADODB.recordset

    How do i assign an OO4O resultset obtained within and oraDynaSet object to an ADODB.recordset (without having to parse the dynaset and .addnew the adodb rs).
    help.

    They are not compatible objects as you already found out. Bookmarks are not interchangeable either.

  • SSRS Tablix not showing full resultset. Recordset seems truncated.

    Hi,
    I have created a tablix for Test Results History as shown below. All components are added inside of a Rectangle (container). 
    Issue:
    1) This table failed to show full resultset; recordset got truncated. The query returns 316 records, table displays only 239 records, where 240th record got truncated. Please see below screenshot.
    Investigations/Analysis:
    1) I tested with another query that returns 54 records; all records are displayed. Another query that returns 585; only 215 records are displayed. It seems that the number of records is not the limiting factor; the length of the tablix, or the Rectangle
    (container) may possibly be the culprit.
    Question:
    How do I fix this? Please help!

    Hi Simon,
    I do have parameter defined but the "Display Test Result history" parameter only sets below behaviors:
    1) If False, the Rectangle (container) becomes invisible, and the query would return no result (to increase performance)
    2) If True, the Rectangle (container) becomes visible, and the query return valid results
    The behavior I'm seeing right now is that the table is visible, and results are shown. However, some results are missing.
    You may refer to below code:
    declare @SelectedTestPlans nvarchar(500) /* Testing purpose */
    -- set @SelectedTestPlans = '104' /* Testing purpose */
    set @SelectedTestPlans = '81, 79' /* Testing purpose */
    declare @ShowTestResultHistory bit /* Testing purpose */
    set @ShowTestResultHistory = 'true' /* Testing purpose */
    declare @SelectedIDs TABLE(IDs integer)
    insert into @SelectedIDs
    select * from master.dbo.fnSplitIDs(@SelectedTestPlans)
    declare @TestCaseIdsTable TABLE
    TestCaseId int
    /* Update #00-1 - Populate Only TestCaseId */
    insert @TestCaseIdsTable (TestCaseId)
    select distinct
    TestCaseId
    from ([Tfs_Warehouse].[dbo].[FactTestResult] ftr
    inner join [Tfs_Warehouse].[dbo].[DimConfiguration] dc
    on dc.ConfigurationSK = ftr.ConfigurationSK
    inner join @SelectedIDs s
    on ftr.TestPlanSK = s.IDs)
    where (@ShowTestResultHistory = 'true')
    declare @HistoryTable TABLE
    TestCaseId nchar(36),
    Test nvarchar(256),
    Result nvarchar(64),
    OutcomeId tinyint,
    ConfigurationId int,
    Configuration nvarchar(256),
    CreationDate datetime,
    Name nvarchar(4000)
    INSERT @HistoryTable (TestCaseId, Test, Result, OutcomeId, ConfigurationId, Configuration, CreationDate, Name)
    SELECT DR.[TestCaseId]
    ,[Test]
    ,[Outcome] as Result
    ,[OutcomeId]
    ,C.[ConfigurationId]
    ,C.[Name] as Configuration
    ,[CreationDate]
    ,DP.[Name] as 'Run By'
    FROM [Tfs_Warehouse].[dbo].[DimTestResult] DR
    inner join [Tfs_Warehouse].[dbo].[FactTestResult] TR on DR.ResultBK = TR.TestResultBK
    join [Tfs_Warehouse].[dbo].DimConfiguration C on TR.ConfigurationSK = C.ConfigurationSK
    join [Tfs_Warehouse].[dbo].[DimPerson] DP on DR.ExecutedBySK = DP.PersonSK,
    @TestCaseIdsTable TCID
    Where DR.[TestCaseId] = TCID.[TestCaseId]
    And (@ShowTestResultHistory = 'true')
    Select * From @HistoryTable
    Order By [TestCaseId]
    Hmm.. What am I missing here?

  • Problem in setting the resultset recordset

    hi all,
    i am trying to do paging in my website .. i want to set the records fetched from the resultset...i am using the "rs.setFetchSize(3)"
    i want to show only 3 records per page...
    code is shown below.. problem is it is showing
    "java.sql.SQLException: Invalid Fetch Size"
    exception.... please help me out...
    package demo;
    import java.sql.*;
    public class fetchrecord {
         public static void main(String[] args) {
              Connection con =null;
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:chandan");
              Statement st=con.createStatement();
              String q1="Select * from Table1";
              ResultSet rs=null;
              rs=st.executeQuery(q1);
              rs.setFetchSize(3);
              System.out.println("Details are as follows");
         System.out.println("\n");
              while(rs.next())
              String Name = rs.getString(1);
              String School = rs.getString(2);
              System.out.print(Name+" ");
              System.out.print(School);
              System.out.println("\n");
              }catch(Exception e)
              System.out.println(e);
              try {
              con.close();
              catch (SQLException e)
              e.printStackTrace();
    thanks
    chandan sharma

    as per the api documentation, an exception occurs when the condition 0 <= rows <= Statement.getMaxRows() is not satisfied

  • ResultSet - RowSet - RecordSet

    Hi there,
    I'm a newbie to Flash Remoting. I'm having difficulty
    transferring a result set to flash using an intermittent rowset,
    can anyone help?
    The result to flash is null with either of the
    implementations (commented & uncommented).
    import java.sql.*;
    import javax.sql.rowset.CachedRowSet;
    import com.sun.rowset.CachedRowSetImpl;
    public class JavaClassService {
    public ResultSet getResultSet(){
    Connection connection = null;
    try{
    Class.forName( "com.mysql.jdbc.Driver" );
    connection = DriverManager.getConnection(
    "jdbc:mysql://localhost/test", "root", "space7107");
    Statement stmt = connection.createStatement();
    ResultSet resultset = stmt.executeQuery("SELECT * FROM
    testdata");
    CachedRowSet crs = new CachedRowSetImpl();
    //crs.setUsername("root");
    //crs.setPassword("space7107");
    //crs.setUrl("jdbc:mysql://localhost/test");
    //crs.setCommand("SELECT * FROM testdata");
    //crs.execute();
    crs.populate(resultset);
    resultset.close();
    stmt.close();
    connection.close();
    return crs;
    }catch(Exception e){
    }finally{
    try{
    if(connection!= null && !connection.isClosed())
    connection.close();
    }catch(SQLException e){}
    return null;

    In case anyone has this problem - Sun 1.5 is required to use
    CachedRowset - I had been trying to use 1.4 and the rowset.jar,
    which wasn't working. Both commented&uncommented java code work
    fine with flash remoting.

  • RecordSet  to Cusror Conversion Help Needed

    Hi,
    I have a Perl Code which calls a Stored Procedure in Oracle 8i Database. As you know that you can return Cursors
    and other data types back to Perl and not RecordSets. So I am trying to convert a RecordSet to a Cursor. The Stored
    Procedure Does some complex computations and then stores the results in a record Set. I need to tansfer the data
    from the Record Set back to the Perl Code via a REF Cusror. The only solution that I can think of is Creating a Temp
    Table to store the results and then point a Cursor to that and return that Cusror to the Perl Code. Is there any other
    way of doing this???. I searched lot of sites/forums, But couldnt find any solution.
    You Help will be greatly appreciated :).
    Thanks
    Rajesh

    Hi Rajesh,
    i too had the same requirement but using Java Code.
    One way to return a Cursor to the code is using a package.
    the query which returns the recordset is to be assigned to a ref cursor. For eg.
    CREATE OR REPLACE PACKAGE PKG_PLAN AS
    TYPE RESULT IS REF CURSOR;
    PROCEDURE USERDETAILS2 (
    O_RESULT OUT RESULT
    END PKG_PLAN;
    CREATE OR REPLACE PACKAGE BODY PKG_PLAN AS
    PROCEDURE USERDETAILS2(
                   O_RESULT OUT RESULT
    AS
    BEGIN
    OPEN O_RESULT FOR SELECT DISTINCT US_FIRSTNAME AS UserName,
    US_COMPANYNAME AS Company, TBLUSER.US_PRIMARYEMAIL AS EmailId ,
    FROM
    TBLUSER where
    TBLUSER.US_STATUS = 'A' ORDER BY UserName;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('INSIDE EXCEPTION');
    END USERDETAILS2;
    END PKG_PLAN;
    and in the perl code u will invoke the procedure as
    CALL PKG_PLAN.USERDETAILS2(?)
    where ? is the out parameter -of type cursor which is to be
    registered via perl code.(not sure how it is done in perl)
    and after issuing execute command via perl code
    get the resultset.
    hope u understood it and the above was of help.
    Good luck
    Rani
    Hi,
    I have a Perl Code which calls a Stored Procedure in Oracle 8i Database. As you know that you can return Cursors
    and other data types back to Perl and not RecordSets. So I am trying to convert a RecordSet to a Cursor. The Stored
    Procedure Does some complex computations and then stores the results in a record Set. I need to tansfer the data
    from the Record Set back to the Perl Code via a REF Cusror. The only solution that I can think of is Creating a Temp
    Table to store the results and then point a Cursor to that and return that Cusror to the Perl Code. Is there any other
    way of doing this???. I searched lot of sites/forums, But couldnt find any solution.
    You Help will be greatly appreciated :).
    Thanks
    Rajesh

  • How to determine whether a recordset is Empty or not ?

    Please see my snippet code below :
    <%     
         String sql="";
         String username="CDS";
         try
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con = DriverManager.getConnection("jdbc:odbc:Employees","","");
                Statement stmt = con.createStatement();
                ResultSet rs=null;
                   sql = "Select * from Employee where code='" + username + "'";
                   rs = stmt.executeQuery(sql);
                   rs.next();
                   if (rs==null)
                   %>
                        <jsp:forward page="Login.jsp?msg=Username not recognized"></jsp:forward>     
                   <%     
                else
                   %>
                        <jsp:forward page="Login.jsp?msg=Halo"></jsp:forward>
                   <%
              catch(ClassNotFoundException e)
                   out.println("Driver not found");
                    catch(SQLException e2)
                            out.println(e2.getMessage());
                            out.println("<BR>");
                            out.println("Wrong SQL Statement");
                            out.println("<BR>");
                            out.println(sql);
                            out.println("<BR>");
         %>How to determine whether a recordset has no result ?
    From the above code, i use if (rs==null) and that's not worked.
    Help me, guys.

    ResultSet rs = stmt.executeQuery(sql);
    if (rs.next()) {
    %>
        <jsp:forward page="Login.jsp?msg=Halo"/>
    <%
    } else {
    %>
        <jsp:forward page="Login.jsp?msg=Username not > recognized"/>
    <%
    }

  • Displaying resultset one record at a time

    This is a rather long question, but I have never done any projects like this before with Java.
    I have an application in which users can view each record within a range of values one at a time. I have created a recordset that is sorted by one column in the resultset. What is the best way to display each record using forward/back buttons to "flip" through each record? How would I keep track of which record in the set I am actually displaying so I can move to either the next or previous depending on which button the user selects? Another problem I have is whether a particular button should be disabled?
    Thanks in advance,
    Chris

    Try this link
    http://www.theserverside.com/resources/article.jsp?l=DataListHandler
    Select the Read PDF here link and it will download the PDF for you to read.
    It's a pattern for the sort of problem that you describe. It comes complete with source code that you could use.
    If you wish you can contact me via e-mail and I'll email you a working example.
    Dave

  • Get value from Table/Recordset Cell into a JSP variable

    Can anyone please help with this ?...
    I need to get a cell value from a selected row of a table into a variable to pass to a java bean.
    1 - The dynamic table is populated by a recordset named "rs" and has a submit button for each row .
    2 - The user clicks on the corresponding button to select the row.
    3 - The recordset retrieved the ID for that row in the query, but does not display it in the table.
    I have tried :
    <% String ID = rs.getString("bookid");%>
    <% Library.bookConfirm(ID);%>
    But this fails saying that it "cannot resolve variable rs..."
    Yet the recordset populates correctly and its name is "rs"
    Is there another way to do this perhaps ?... ie: put the id in a column of the table and get the cell value ?...
    What would be the syntax to get the ID cell value of that selected row on the button click ?...
    Your feed back would be greatly appreciated.
    Thank you.

    Create a new rs
    ResultSet rs1 = statement.executeQuery(query);
    and use getstring to access the individual cell.

  • Dts.Events.FireInformation: Output not coming through to recordset

    I am using SQL Server 2008.  I have a SQL Server T-SQL procedure that uses a shell command to execute a batch file.  The batch file uses DTExec to execute an SSIS package.  The T-SQL procedure is called from a Microsoft Access from end using
    ADODB.  All of this works satisfactorily, and the ADODB returns a result set that includes the execution results of the SSIS package and anything else that is in the batch file, such as 'Whoami'. 
    The execution results returned to Access are basically the same as those generated in BIDS when the package is executed in debug mode.  However, I have included script tasks with Dts.Events.FireInformation commands.  This generates lines that
    are present in the debug mode execution results, but are not in the recordset returned to Access.  Do I have to log these lines and retrieve them from the log, or is there a simple way to force their inclusion in the resultset returned to Access.

    The Dts.Events.FireInformation writes to the console pipe, not the resultset.
    I'd say they are redundant, you should write to a log table / file.
    Arthur
    MyBlog
    Twitter

Maybe you are looking for

  • ITunes won't recognize my iPhone 4, wants me to restore to factory settings?

    I'm running iTunes 10.4 with an iPhone 4 OS 4.2.1. I tried to sync my iPhone but got this message: "iTunes cannot read the contents of the iPhone. Go to the Summary tab and click Restore to restore to factory settings." This is not a jailbroken phone

  • I keep getting reminders in Japanese, not sure how to eliminate?  さんは「M

    I keep getting iCloud related Japanese reminders, not sure how to eliminate?  さんは「M&M」への参加依頼を承諾しました. 日時 年2月7日火曜日.07:00 - 10:00 繰り返しイベント 場所 Whereever 参加者 [email protected]とご自身 iCloudはAppleの提供するサービスです. My Apple ID | Copyright © 2014  Apple Inc. All rig

  • Multi Select Prompt DEFAULT VALUE

    Hi, i have following problem: I have two multiselect prompt Country with all Countries and Day with values from 1 to 31. When i load dashboard page, the first and second prompt are empty. First and second prompt have as default value "Report Default"

  • Offline approval setup for SRM 7

    Experts, I have feq uestions on OFFLINE APPROVAL set up in SRM 7. 1. Do I need to scehdule the report /SAPSRM/OFFLINEAPPROVALGET for the inbound emails to be prcoessed and status for shopping carts/PO correctly updated? 2.Do the backgorund jobs (for

  • Having an issue with CS6 pattern maker

    Ive been trying to get a seamess pattern usings a number of different shapes but something keeps stumping me.... I do as all the tutorial say and yet it continally produces faint lines (which i assume are the join lines?) on some of the shapes. How d