Implement paging (prev/next) for jtable data obtained from database

Hello all, first time poster and relative newbie to java.
I am trying to learn java and in the process have stumbled upon this issue.
I have searched through the forum as well as googled my way around for answers. And though I am more informed than I was, I still am a little stumped.
I would like to implement a table that pulls data from a database (mysql), limits the results, and include prev/next buttons to traverse through the records.
I think this involves writing my own AbstractTableModel. And I have seen some examples as such. But could use a little more help.
I will always be pulling 10 rows, but the columns will change depending on query I am using so implementing a more generic set of methods would be great.. To be specific...
Table: users
Columns: userid, ufname, ulname, utype, ustatus, etc....
For selection purposes I only need to show: userid, ufname, ulname. So I figure I write a query like:
select userid, ulname, ufname from users limit index, 10
Where index tells the query where to start from then use the results to populate the jtable. I can do this statically but do not quite understand how to implement the next/prev buttons so that the table pulls the next or previous set of data.
If this can happen without the need to repaint/refresh the frame that would be great.
sudo code (with comments) would be ok, but a basic working example of this would be even better.
thank you in advance, if more information is required please let me know.

tumbleweeds roll by...........

Similar Messages

  • Looking for function or vi to calculate 1/2 power points of data obtained from peak detection vi

    I am analyzing vibration data and need a function or vi that will operate on peak data returned from the LabView Peak detection function and provides 1/2 power points or sideband frequencies. These are needed to compute a "Q" factor. So far I have not been able to find anything.
    Thanks, Fran

    The sound and vibration toolset may help here.  there are several vibration level measurements including peak.  With the advanced FFT functions in the Sound and Vibration tools, the zoom FFT can be used to identify and find sidebands and associated amplitudes. 
    here is a link to the manual
    http://digital.ni.com/manuals.nsf/websearch/1F8691E94728BDF5862570490058C3B2
    here is a link to the toolset
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/10521
    please note the bullets on the above page (about half way down) noting peak detection, etc.
    Preston Johnson
    Principal Sales Engineer
    Condition Monitoring Systems
    Vibration Analyst III - www.vibinst.org, www.mobiusinstitute.com
    National Instruments
    [email protected]
    www.ni.com/mcm
    www.ni.com/soundandvibration
    www.ni.com/biganalogdata
    512-683-5444

  • Caching data read from database

    I have a big performace problem in our J2EE application. We use jsp and servlets to process a request. Servlet gets the results from database which are stored in a vector of dataobjects and vector is stored in session. We display only 20 rows in jsp and provide page navigation to view more data by Next and Prev links. The problem is we want to store results in request object instead of session variable but then that data is not availabe for Next and Prev links. We don't want to do another search to view more data. Is there a way to cache the data so that while view more data by page navigation we don't need to hit database since request object would be cleared at that time. I am clueless. I hope I explained the problem properly. Any help on this would be highly appreciated

    You're not clueless, you said it yourself.
    To make info available over multiple requests, you need to use a session variable rather than the request.

  • CRVS2010 beta - Date field from database does not display in report

    Hi there - can someone please help?!
    I am getting a problem where a date field from the database does not display in the report viewer (It displays on my dev machine, but not on the client machines...details given below)
    I upgraded to VS 2010
    I am using the CRVS2010 Beta
    My development machine is Windows 7 - and so is my fellow developer's
    We are using Microsoft SQL Server 2000
    We run the queries within VS and then we send the data table to VS using .SetDataSource
    We have a few reports which display the date on our dev machines (whether we run the EXE or from within Visual Studio)
    When we roll out to the client machines (running Windows XP SP3) then everything works, except that the date does not display (on quite a few reports)
    This is the only real issue I have had - a show stopper for me
    The rest works well - any input will be greatly appreciated
    Regards,
    Ridwan

    Hi Ridwan,
    After much testing I have it all working now using CRDB_adoplus.dll as a data source ( XML )
    Alter your Config file to look like this:
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
    </startup>
    Then using the code below, and CR requires the Schema to be able to read the date format.
    private void SetToXML_Click(object sender, EventArgs e)
    CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
    ISCDReportClientDocument rcd;
    rcd = rptClientDoc;
    string connString = "Provider=SQLOLEDB;Data Source=dwcb12003;Database=xtreme;User ID=sb;Password=password";
    string sqlString = "Select * From Orders";
    OleDbConnection oleConn = new OleDbConnection(connString);
    OleDbDataAdapter oleAdapter = new OleDbDataAdapter(sqlString, oleConn);
    //OleDbDataAdapter oleAdapter2 = new OleDbDataAdapter(sqlString2, oleConn);
    DataTable dt1 = new DataTable("Orders");
    oleAdapter.Fill(dt1);
    System.Data.DataSet ds = new System.Data.DataSet();
    // We need the schema to get the data formats
    ds.WriteXml("c:
    sc.xml", XmlWriteMode.WriteSchema);
    //Create a new Database Table to replace the reports current table.
    CrystalDecisions.ReportAppServer.DataDefModel.Table boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Table();
    //boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
    PropertyBag boMainPropertyBag = new PropertyBag();
    //boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
    //In the main property bag (boMainPropertyBag)
    PropertyBag boInnerPropertyBag = new PropertyBag();
    //Set the attributes for the boInnerPropertyBag
    boInnerPropertyBag.Add("File Path ", @"C:\sc.xml");
    boInnerPropertyBag.Add("Internal Connection ID", "{680eee31-a16e-4f48-8efa-8765193dccdd}");
    //Set the attributes for the boMainPropertyBag
    boMainPropertyBag.Add("Database DLL", "crdb_adoplus.dll");
    boMainPropertyBag.Add("QE_DatabaseName", "");
    boMainPropertyBag.Add("QE_DatabaseType", "");
    //Add the QE_LogonProperties we set in the boInnerPropertyBag Object
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
    boMainPropertyBag.Add("QE_ServerDescription", "NewDataSet");
    boMainPropertyBag.Add("QE_SQLDB", "False");
    boMainPropertyBag.Add("SSO Enabled", "False");
    //Create a new ConnectionInfo object
    CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =
    new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
    //Pass the database properties to a connection info object
    boConnectionInfo.Attributes = boMainPropertyBag;
    //Set the connection kind
    boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
    //*EDIT* Set the User Name and Password if required.
    boConnectionInfo.UserName = "";
    boConnectionInfo.Password = "";
    //Pass the connection information to the table
    boTable.ConnectionInfo = boConnectionInfo;
    //Get the Database Tables Collection for your report
    CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;
    boTables = rptClientDoc.DatabaseController.Database.Tables;
    //For each table in the report:
    // - Set the Table Name properties.
    // - Set the table location in the report to use the new modified table
    boTable.Name = "Orders";
    boTable.QualifiedName = "Orders";
    boTable.Alias = "Orders";
    rptClientDoc.DatabaseController.SetTableLocation(boTables[0], boTable);
    //Verify the database after adding substituting the new table.
    //To ensure that the table updates properly when adding Command tables or Stored Procedures.
    rptClientDoc.VerifyDatabase();
    MessageBox.Show("Data Source Set", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
    Thanks again
    Don

  • Reading Data Clusters from Database ??

    Hi at all,
    how can I read Data from a ClusterTable´`?
    In the Database "STXL" is a field "CLUSTR" and "CLUSTD" and i want see the input. But before i can see it, i must read this Data Cluster.
    How does it work``?
    IMPORT tab = itab
    FROM DATABASE stxl(tx)
    ID   wa_TDOBJECT
    TO wa_stxl.

    well, normally you got FM´s which enable you to do selects or whatever with cluster tables.
    in your case it would be FM READ_TEXT or related FM´s. I do ABAP programming for quite a while now, and i never came to the situation where i manually had needed to read a cluster table.

  • SQL Data Access from database

     Hi Friends,
     I want to access data from database, User will enter Start Date and end date , based on that , data will be get retried.
    Is it possible to write a SQL Query, Where A SQL Query will take care user start and end date. Start date and end date is not fixed, it will be vary based on user.
    Thanks for co-operation.
    Regards,
    Pritam A.

    Pritama,
    Yes, your query looks fine. It should work perfectly. You could alternatively, get input from user into variables and use them in your query as shown below:
    declare @user_startdate datetime
    set @user_startdate='10/Oct/2013 1:00:04'
    declare @user_enddate datetime
    set @user_enddate='14/Oct/2013 1:00:04'
    SELECT * FROM GT1
    WHERE datetime1 BETWEEN @user_startdate AND @user_enddate
    Is there anything else you are facing a problem with? Your query is correct and gives no problems..
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • To implement a hash structure for multidimensional data

    hi
    I have to implement a hash structure (multidimensional data) i.e., like
    a Grid file. I have to find data points in the given range of the grid file.
    Any one could help me ....
    Thanks

    hello
    Thanks for your quick reply and sorry for the bad
    explanation. What I meant was a 2-dimensional graphI'm still not sure I know what you're after. I assume what you're saying here is that you have a collection of vertices and edges, and they all lie in the same plane. Is that right?
    which was divided into some fragments.So, does this mean you have a collection of subgraphs of your main graph?
    We can insert
    some points dynamically, based on their coordinate
    axes, into one of the fragments.And here do you mean that you have some rule that allows you to add another vertex and associated edge list to a given fragment at runtime?
    >
    It is similar to the implementation in the links that
    you had sent me.
    Could you give me some outline to implement it ...I don't have enough information to do that.
    You could define a data structure to represent one Vertex/Edge-List pair. But then, maybe you don't need to work with vertices so much as Edges? Then you could define a data structure to represent a Vertex, then another to represent an Edge, which would be two vertices. And you might want to think of your "main" Graph as a single entitity, in which case you will need a field to show what fragment this vertex (or edge) belongs to. But then it might make more sense to have seperate data structures for all fragments in which case you wouldn't.
    Too many open questions. What, exactly, do you want to do with this thing?
    Good Luck
    Lee

  • Best way to store data obtained from a resultset !?

    Hi all,
    I am working on a verification process that is to be run on our DB upon every external db extraction prior to merge into our DB (which is being done manually now)
    What I have decided so far is to have a verifier interface that is implemented by a bunch of *Verifier classes.
    Then depending on the level of verification, a subset of these verifiers would run and populate a generic result object (per verifier) with the query results and whether the verifier passed or not.
    I was thinking of having the Result class employ a JTable to store the query result (from a resultset), but I can't seem to find a way to retrieve the data from the Jtable row by row (I'd like to obtain the result from the JTable row by row as it would be easy to format) or the entire table to display for that matter.
    Please advise if you think this is a good approach? and if JTable's a good idea!? if yes, how should i use it? otherwise, what would you suggest?
    Thanks a lot,
    Cheers,
    parachuter2b

    BigDaddyLoveHandles wrote:
    There's no need for a "table". Use a List<YourBusinessClass>. If you don't know collections take the tutorial:
    |http://java.sun.com/docs/books/tutorial/collections/index.html]Thanks, that's what I sort of did:
    I figured how to use the ResultSetMetaData to get the column names and therefore generate a report from any query by having its resultset.
    so created a Result class, which holds the resultset of the query, plus a boolean that indicates whether the verification passed or not.
    Now what I have problem with is formatting the resultset and displaying it nicely in a report. The problem is that the length of the values in the resultset are variable and using constant indentation doesn't work. What's the easiest way to get around this apart from going through the resultset once before displaying the report to calculate the indentations for every single item?
    Thanks,
    parachuter2b

  • How to set null value for a date column using database adapter

    Hello,
    I have a table wih 3 columns
    (id NUMBER,
    modified_on DATE
    contentText VARCHAR2)
    I have a row wih theses values (1, 20/03/2010 16:30, 'coucou')
    I want use a DB adapter in a BPEL process to change the value of column modified_on to (null). I'm using the out-of-he box "update" method (no custom sql, nieher "insert or update (merge)" method)
    - If I only set values of "Id" and "contentText" -> insert is done but I missed the modification of "modified_on" to (null)
    - If I set all values and use expression '' (2 single quote without any space) for modified_on I got an error on update
    BWriteInteractionSpec Execute Failed Exception.
    update failed. Descriptor name: [DBUTFORM.TForm]. [Caused by: String index out of range: 10]
    Caused by Exception [TOPLINK-3001] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object [xs:datetime], of class [class java.lang.String], could not be converted to [class java.sql.Timestamp].
    Internal Exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 10.
    Thanks for help

    1008318 wrote:
    its my personal need..then it is a very bad personal need. DATE is not an appropriate type to be using for a primary key, as it cannot be guaranteed to be unique, especially when inserting multiple rows at once.
    You would be better working to business needs and implementing correct technical solutions to those needs, than to just do things based on your personal needs.

  • What's wrong with my code for comparing date retreived from db and sysdate?

    Hi all,
    I need to retrive date from the DB and compare it to system date.i have posted the code below.i get java.sql.SQL Exception:Io exception:Socket closed.
    What's wrong with the code?please help me.Thanks in advance.
    public boolean date() throws IOException, SQLException {
    Connection con1;
    long millis = System.currentTimeMillis();
    Timestamp timestamp = new java.sql.Timestamp(millis);
    ResultSet rs4 = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@abc:1605:xyz",
    "cdf", "cdf");
    Statement stmt_exp = con.createStatement();
    rs4 = stmt_exp.executeQuery("SELECT DATE FROM TABLE_NAME")
    while (rs4.next()) {
    Timestamp timestamp2 = rs4.getTimestamp("expire_date");
    con1.close();
    catch (Exception e)
    e.printStackTrace();
    finally
    //ResultSet rs4 = null;
    //Timestamp timestamp2;
    Timestamp timestamp2 = rs4.getTimestamp("expire_date");
    if (timestamp2.compareTo(timestamp) < 0)  //sysdate < exp date
    return true;
    } else {
    return false;
    }

    Didn't you understand what BalusC said? You're closing the connection and then trying to use the ResultSet. The ResultSet will be closed when you close the connection so you can't use it anymore.
    You should close the connection last thing in your code, probably in a finally. And after you close your ResultSet and Statement.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • FM for validating date coming from a file

    HI All,
    I have to validate date that needs to be validated before passing it to DB.
    Is der any FM for same
    I tried CONVERT_DATE_TO_INTERNAL.
    But it accepts date only in one specified format.

    hi,
    try this
    Use Function module DATE_CHECK_PLAUSIBILITY to validate a date.
    1)If you given a invalidate date then it will ask you to enter a valid date.
    2)After changing it to correct value, you can click on SAVE button or if you want to continue with the invalid date then click on USE INVALID VALUE button.
    Try with this code.
    PARAMETER P_DATE TYPE SYDATUM.
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
    EXPORTING
    date = P_DATE
    EXCEPTIONS
    PLAUSIBILITY_CHECK_FAILED = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE E000(ZI) WITH 'INPUT DATE IS INVALID DATE'.
    ENDIF.
    Regards,
    RItesh J

  • Tools for migrating data (documents) from MS SQL to Oracle

    Hi,
    Please let me know if there any tools available for migrating documents from one database like MS SQL to Oracle. Currently our documents are stored in MS SQL and we are planning to implement KM for document management with Oracle as the database.
    Regards,
    Suresh

    The old manual style still works - create the scripts for the migration objects, then use search & replace to rename the schema for all affected objects and finally run the SQL script to create them in the Oracle database.
    - Klaus

  • Event for executing data automatically from PI to BI

    Hi,
    We are using web service for data source. For that we have created a source system web service and we are using PI for transfering flat file data into BI through web service and data source is in BI which is updating data into BI base DSO.
    In this PI push the file and data uploaded into BI but this is a manual. Is there any event when PI push the file and the process chain executed automatically because we have to run process chain manually in BI.
    Regards

    With New G/L in R/3, the tables FAGLFLEXT (totals), FAGLFLEXA, BSEG, BKPF (Line Item) get filled. in BI side u have to use following data model
    0FI_GL_10 -> 0FI_GL_10 -> 0FIGL_C10 -> 0FIGL_V10(for Totals)........Datasource 0FI_GL_10 is based on table FAGLFLEXT
    0FI_GL_14 --> 0FIGL_O14 (for Line item).  .. ....          .......Datasource 0FI_GL_14 is based on tables FAGLFLEXA, BSEG, BKPF
    SAP delivered function module RS_BCT_FIGL_DATA_GET_VC10 pulls data from 0FIGL_C10 to load 0FIGL_V10... Logic for cumulative balances considering carry forward balances from previous year for Balance sheet & P/L reports, is maintained in that function module.
    (So, make sure this FM got installed while u installed standard content for GL model
    Do the following, to see weather FM got installed.
    Goto change mode of virtual provider (ZFIGL_V10). click information icon (blue 'i')
    click 'Type/ Namespace'.. Then click 'details' button
    If there is no FM, u won't get any data to 0FIGL_V10 and related queries.
    And also 0FIGL_V10 uses Financial Statement Version object (0GLACCEXT), which is not available in 0FIGL_C10.
    For Balance sheet & P/L reports, 0GLACCEXT is key object, so 0FIGL_VC10 is must.
    U should install & load master (attr, hier, text) data for 0GLACCEXT.
    http://help.sap.com/bp_bw370/BBLibrary/documentation/B70_BB_ConfigGuide_EN_DE.doc

  • How to Read the internal table for the data download from the spool

    HI all,
    I have one issue regarding the spool ,we are getting the correct output as per requirement of  user but when we send the same to the user in pdf format they did notget the same.
    they are telling that the due date is missing from the pdf.
    Please advice me how to track the internal  table for the spool data converted intopdf in a readable format.
    the FM used for the above task is : 
    call function 'CONVERT_OTFSPOOLJOB_2_PDF'
    Please reply if any one worked on the same.
    Thanks in advance.
    Gaurav,

    Hi Wang,
    Please let me know how you solved your question.
    Points will be rewarded.
    Thanks,
    Arun.

  • Hierarchy for Master Data Load from BW

    Hi All
    I'm loading Master data from BW infoobject 0Customer. There is no Hierarchy maintained for it in BW.
    Rather than creating hierarchy manually in BPC, I want to include mapping in transformation/conversion file which should roll master data records coming from BW to ALL_CUSTOMERS (member manually maintained in BPC). ALL_CUSTOMERS will be parent node for the hierarchy in BPC. No other levels of hierarchy is required. All the data should have one parent.
    Something like PARENT=*STR(ALL_CUSTOMERS)
    Please share your ideas? Help is very much appreciated.
    Thanks.

    Hi Asif
    If you are laoding master data from BW infoobject, you will not be able to load /specify any value for ParentH1/hierarchy node as BW /BPC does not allow that.
    An option would be to
    1) load hierarchy from a flat file or
    2) to maintain  hierarchy in BW amd load into BPC the normal way
    Regards
    Surabhi

Maybe you are looking for