How to put data in JTable from database

hi everyone,
i want to query the databse and put the result in the JTable and if possible i want to edit some information. For example: i have 5 records in the database query them and place them in JTable and each record has its own status. if i want to change the status For Example: the status of the 4 records are "Cleared" and the other one is "RELEASEd" so if i have JCombo Box to set the 4 records in to RELEASED status and then save the changes is that possible?
thank you
dhing

In [url /thread.jsp?forum=54&thread=387565]this thread I describe how to use a result set as a basis for table data. Check some database tutorials for information on getting a result set.

Similar Messages

  • How to get data in jtable from database

    i m working on core java application i want to use jtable to show records to user. jtable will get records from mssql database. how to do this.. i m new so plz tell me briefly..with coding...
    thanks

    i have use this link:
    import java.sql.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    * This class takes a JDBC ResultSet object and implements the TableModel
    * interface in terms of it so that a Swing JTable component can display the
    * contents of the ResultSet. Note that it requires a scrollable JDBC 2.0
    * ResultSet. Also note that it provides read-only access to the results
    public class ResultSetTableModel implements TableModel {
    ResultSet results; // The ResultSet to interpret
    ResultSetMetaData metadata; // Additional information about the results
    int numcols, numrows; // How many rows and columns in the table
    * This constructor creates a TableModel from a ResultSet. It is package
    * private because it is only intended to be used by
    * ResultSetTableModelFactory, which is what you should use to obtain a
    * ResultSetTableModel
    ResultSetTableModel(ResultSet results) throws SQLException {
         this.results = results; // Save the results
         metadata = results.getMetaData(); // Get metadata on them
         numcols = metadata.getColumnCount(); // How many columns?
         results.last(); // Move to last row
         numrows = results.getRow(); // How many rows?
    * Call this when done with the table model. It closes the ResultSet and
    * the Statement object used to create it.
    public void close() {
         try { results.getStatement().close(); }
         catch(SQLException e) {};
    /** Automatically close when we're garbage collected */
    protected void finalize() { close(); }
    // These two TableModel methods return the size of the table
    public int getColumnCount() { return numcols; }
    public int getRowCount() { return numrows; }
    // This TableModel method returns columns names from the ResultSetMetaData
    public String getColumnName(int column) {
         try {
         return metadata.getColumnLabel(column+1);
         } catch (SQLException e) { return e.toString(); }
    // This TableModel method specifies the data type for each column.
    // We could map SQL types to Java types, but for this example, we'll just
    // convert all the returned data to strings.
    public Class getColumnClass(int column) { return String.class; }
    * This is the key method of TableModel: it returns the value at each cell
    * of the table. We use strings in this case. If anything goes wrong, we
    * return the exception as a string, so it will be displayed in the table.
    * Note that SQL row and column numbers start at 1, but TableModel column
    * numbers start at 0.
    public Object getValueAt(int row, int column) {
         try {
         results.absolute(row+1); // Go to the specified row
         Object o = results.getObject(column+1); // Get value of the column
         if (o == null) return null;
         else return o.toString(); // Convert it to a string
         } catch (SQLException e) { return e.toString(); }
    // Our table isn't editable
    public boolean isCellEditable(int row, int column) { return false; }
    // Since its not editable, we don't need to implement these methods
    public void setValueAt(Object value, int row, int column) {}
    public void addTableModelListener(TableModelListener l) {}
    public void removeTableModelListener(TableModelListener l) {}
    the table is showing column name from database but not showing the data in row now what to do

  • How to display data in SelectOneChoice from database?

    Hi,
    I want to display data in SelectOneChoice component after fetching from database in a bean using Application module implementation class. I have two fields in my bean id and name. I want to display name in choice and in backend i want to play with the id of corresponding selected choice i.e displayed in SelectOneChoice. I am not able to bind the datacontrol with the SelectOneChoice component. I have data in my bean i.e list of id and name fetched from database.

    In my app module i have create a method which retruns UserBean in array List .
    I dropped that data control on my page as Select One Choice and bind the same.
    When i run that page I am able to see user bean object in drop down but when i try to see any specific var error occurs
    Code-
    <af:selectOneChoice value="#{bindings.return.inputValue}"
    label="#{bindings.return.label}"
    required="#{bindings.return.hints.mandatory}"
    shortDesc="#{bindings.return.hints.tooltip}"
    binding="#{backingBeanScope.backing_test12.soc1}"
    id="soc1">
    <f:selectItems value="#{bindings.return.items}"
    binding="#{backingBeanScope.backing_test12.si1}"
    id="si1"/>
    </af:selectOneChoice>
    This code works fine and drop down shows userbean .
    But when i change the code it fetch username form bean exception occurs
    Changed Code-
    <f:selectItems value="#{bindings.return.items.*Username*}"
    binding="#{backingBeanScope.backing_test12.si1}"
    id="si1"/>
    Exception-
    *[ServletContext@15368949[app:ADF module:ADF-ViewController-context-root path:/ADF-ViewController-context-root spec-version:2.5]] Servlet failed with Exception*
    java.lang.NumberFormatException: For input string: "Username"
    *     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)*
    *     at java.lang.Integer.parseInt(Integer.java:449)*
    *     at java.lang.Integer.parseInt(Integer.java:499)*
    *     at javax.el.ListELResolver.toInteger(ListELResolver.java:373)*
    *     at javax.el.ListELResolver.getValue(ListELResolver.java:167)*
    *     Truncated. see log file for complete stacktrace*
    FYI:- This control wokrs fine when i but this data in table . Not sure about the reason for select choice :(

  • How to import data into JTable from a text file?

    thanks in advance!

    My guess is you will have to read the data in from the file, parse it, populate some vectors or something and use those vectors to instantiate the JTable. You could use FileReader to read in the data:
    FileReader in = new BufferedReader(new FileReader(file));then use StringTokenizer to parse it.
    m

  • How to dynamic order of groups & How to fetch data at runtime from database

    Post Author: ferikpatel
    CA Forum: Formula
    I am using visual studio .net application having inbuilt crystal report feature. Now, what I want to do is, i have create 5 groups in crystal report, but dynamically want to change the order of those reports as per user's selection.
    How to do that?
    Also, how to fetch database item on runtime which is not selected through data expert as its relation is depends on situation. Say if one field's value is 5 than i want to get name of customer, but if same field's value is 6 than i want to get name of suppliers. In database both supplier and customers tables are different however they are connected with base table.
    I'm bit new in crystal report. Please help me out if it is possible.

    Post Author: Charliy
    CA Forum: Formula
    You don't actually change the order of the groups.  You group on a formula and change contents of the formula based on the parameter.
    IF {?Group1} = "Manager" then {table.Manager}
    else if {?Group1} = "Invoice Date" then Totext({table.InvDate},"yyyyMMdd")    note all options must be the same date type, so numbers and dates are converted
    else . . .

  • How to put datas from database in html�s forms?

    Does anyone have any idea how to put datas from the database using JSP???

    One option: put your data into a JavaBean and then put that into the session. You can then access it from your JSP. You can access the properties of the bean using the basic JSP scripting elements, or if you want to get fancy, both JSTL and Struts have a bunch of custom tags for working with JavaBeans.

  • How to put data into a RFC import parameter structure from portal

    Hi, All,
    I have a RFC in which an import parameter is a structure (not a table). I want to put data into that structure. I know how to put data into a table or a string. I tried to use
    IRecordSet MyTABStr = (IRecordSet)structureFactory.getStructure(function.getParameter("MYTABSTR").getStructure());
    MyTABStr.setString("FIELD1", value1);
    MyTABStr.setString("FIELD2", value2);
    importParams.put("MYTABSTR",MyTABStr);
    But it works for table not structure.  Is there anybody know how to do that?
    Thanks in advance!
    Meiying

    Hi,
    You can try the following code -
    IRecord structure = (IRecord)structureFactory.getStructure(function.getParameter("MYTABSTR").getStructure());
    structure.setString("FIELD1", value1);
    structure.setString("FIELD2", value2);
    importParams.put("MYTABSTR",structure);
    Regards,
    Sudip

  • How can I send a message from database to a J2EE application?

    How can I send a message from database to a J2EE application?
    If I have a codetable in database that has new or modified values I have to refresh the codetable in my J2EE application.
    Most effective way would be send a message to initiate a table reload from J2EE app, but I don't know how to do this.
    Now I have a background thread that regular reads the table and looks for changes.

    http://www.oracle.com/technology/products/integration/bam/10.1.3/TechNotes/TechNote_BAM_AQ_Configuration.pdf
    This document details how to create triggers on a table that send out JMS messages.
    In this example, the messages are going to Oracle BAM.. your message could go to your J2EE application listening to its own topic/queue.
    an alternative idea.
    you could also just cache your lookup table with something like Oracle Coherence and than try to ensure that all changes to the lookup go through Coherence, so that you won't need to do notification from the db up to the application. the application and the lookup data management tool would be using the data grid for management of the lookup table data, and the data grid (coherence) would persist the lookup data changes back to the db.

  • I tried to sinc my photos and i ended up deleting off my phone all the pictures.  i only ended up with one folder, and i cant figure out how to put rest of folders from my computer back on my phone.....help

    i tried to sinc my photos and i ended up deleting off my phone all the pictures.  i only ended up with one folder, and i cant figure out how to put rest of folders from my computer back on my phone.....help
    and on a second problem.  I need to know for sure that my contacts are backed up on my computer

    Create a parent folder on your computer to store the named folders of photos that you want transferred to your iPhone. Under the Photos tab for your iPhone sync preferences with iTunes, select the parent folder. All named folders of photos within will be transferred to your iPhone as separate folders or albums.
    Regarding your 2nd question, this should be easy. Your contacts should be available on your computer with or without an iPhone or any cell phone, which can be lost or stolen.
    Although contacts are included with your iPhone's backup which is updated by iTunes as the first step during the iTunes sync process, not a good idea to depend on this either since the iPhone backup includes a significant amount of other data. Contacts are designed to be synced with a supported address book app on your computer. With Windoze, this can be with Outlook 2003, 2007, or 2010 along with syncing calendar events and notes, or with the address book app used by Outlook Express with XP and by Windows Mail with Vista and Windows 7 called Windows Contacts for syncing contacts only.

  • How to mask data in oracle 11g database release 1

    how to mask data in oracle 11g database release 1
    my environment is
    Database: 11g release 1
    os: AIX 6 (64 bit)
    GC:10g release 1

    DBA-009 wrote:
    thx but how i can mask data with above give environment?What does "mask data" mean to you and what is the environment you are referring to?
    Telling us that you are using 11.1 helps. But it is far from a complete description of the environment. What edition of the database are you using? What options are installed? What Enterprise Manager packs are licensed? Is any of this changable? Could you license another option for the database or another pack for Enterprise Manager if that was necessary?
    What does it mean to you to "mask data"? Do you want to store the data on disk and then mask the data in the presentation layer when certain people query it (i.e. store the patient's social security number in the database but only present ***-**- and the last 4 digits to certain sets of employees)? Do you want to hide entire fields from certain people? Do you want to change the data stored in the database when you are refreshing a lower environment with production data? If so, do you need and/or want this process to be either determinisitic or reversable or both?
    Justin

  • How to setup Data guard for SAP database?

    Can someone please tell me how to setup data guard for SAP databases?
    Thanks,
    Abhi

    Hi Abhi,
    have a look at OSS 105047 - Support for Oracle functions in the SAP environment you find this under
    14
    Oracle Data Guard
    You can use "Physical Standby".
    You cannot use "Logical Standby".
    You are allowed to use Fast Start Failover (FSFO) but SAP Support is not provided.
    You can use Data Guard Broker.
    You can use Maximum Performance Mode, Maximum Availability Mode and Maximum Protection Mode.
    In the case of Maximum Availability and Maximum Protection, you must pay particular attention to a fast network connection in order to avoid performance problems.
    Maximum Protection causes the primary database to terminate if problems occur in the standby database.
    And here you find on Oracle white paper from 2010 http://www.oracle.com/us/solutions/sap/wp-ora4sap-dataguard11g-303811.pdf
    Perhaps some SAP user have answers for you http://scn.sap.com/community/oracle/content?query=guard
    regards
    Kay

  • How to view data in Xcelsius from an external Excel file

    Hi Everyone,
    i wonder if you know How to view data in Xcelsius from external Excel file and not depend only on the emebded excel sheet.

    Hi,
    As per my understanding, excel has to be imported in Xcelsius to draw up the dashboard. Your aggregated data sits in the xlf file. Using an external excel file will not be possible (I guess).
    One of the ways to connect to an external excel, is the use XML Maps but then your data has to be in the form of XML which will be pulled into excel first and then needs to be brought in Xcelsius using Data Manager.
    You can explore XML Maps in xcelsius in SDN.
    Regards
    Nikhil

  • How to download data in excel from web report in sap ?

    how to download data in excel from web report made  in sap abap?
    through tcode smw0.

    for exemple using
    MS_EXCEL_OLE_STANDARD_DAT

  • How-to extract data in chunks from one R3 to another R3 system

    Does anybody know how to extract data in chunks from one system to another? Imagine you would like to extract 1M records in chunks of 10K records, how would you do it between 2 different R3 systems? A cursor (even with hold) doesn't work
    Any suggestion appreciated
    Thanks
    Ioan

    Hi Ioan,
    I'd do it with fm : TABLE_ENTRIES_GET_VIA_RFC (with where clause-tab)
    or fm GET_TABLE_RFC (get all items)
    regards Andreas

  • Flex / Data / Create Application from Database

    Hi, I had a question,
    When I create an application from a Database (Flex / Data /
    Create Application from Database).
    Can I modify the coded to convert it into a module?
    I have a main application that I would like to load the
    Database as a module. I tried replacing the <mx:Application>
    Tags to Module but didn't work...
    Thanks.

    Hi,
    no. no answer as yet. Seems to be a connection issue with the
    Windows 2003 Server, although all the seetings are correct.
    I installed WAMP Server 2.0 locally to see if I can get the
    project running locally, and it works fine. I can connect no
    problem to the MySQL Database on my local PC. I might just have to
    migrate everything over manually once the project is
    complete.

Maybe you are looking for

  • Please see why this is not working

    hi everyone! Please spare ur time to see what's wrong in this code: I have written this code for a GUI which checks for 4 types of punctuation errors in .txt files. The code compiles correctly and the Gui also appears nicely but when I Give a pathnam

  • Mirroring or streaming Imac on TimeWarner TV with AppleTV box attached?

    Wireless setup if possible.

  • Front Panel 3D Plot Object will not load

    Hello Everyone, I'm having a problem on a particular PC in our lab where, when I attempt to place the 3D graphing object, it does not appear on the front panel. The associated subVI objects appear in the block diagram but if I try to right click and

  • DR Server: Standby Database

    Hello All, I need to Design a DR Server for my Client. I have decided to go for a hot Standby Database. I am very new to DB2. Are there any Documents that can help me on designing the procedure for this. If you can let me know the steps/commands in d

  • Trackpad scroll function not working in any app - tried everything

    Hello. This is my 1st time writing in the forums, and although I have read multiple threads on this issue, nothing has yet solved my problem, including: http://support.apple.com/kb/TS1248, & http://support.apple.com/kb/TS1449. SO ANY HELP IS WELCOME!