JTable: RFC on good practice (SQL queries from cell editor)

I usually add/remove/edit JTable data from an external panel. But in this scenario, my client would like to be able to click on the first column of an empty row and enter a product number. Within the cell editor, I must make an SQL query to the database in order to determine if the product number is valid and if so, use part of the SQL data to populate other cells of the current row (like product description).
My problem is that this just doesn't seem right! Isn't the cell editor executed on the only Swing thread? Also, if the product number is not valid, I correctly implement the stopCellEditing() method but for some reason, you can still navigate the table (click on any other cell or press the TAB key, etc)... weird!!
Does anyone have a good practice on how to perform the SQL query in a better place and force a cell to be selected until you enter a valid number or press the CANCEL key?
I was looking at implementing the TableModelListener's tableChanged(...) method but I'm not sure if that would be a better place either.
I personally would edit outside of the table, but good practice seems hard when the requirement is to edit from a cell editor!!
Any suggestion would be greatly appreciated!
Thanks!

maybe you could write an input verifier for the column that does the query and rejects invalid entries.
maybe you could send the query off in a worker thread.
as far as making the table so you can't select any cells, hmm. not sure.
you could disable
.setEnabled(false);the table until the query comes back, something like that.

Similar Messages

  • SQL queries from a Citadel database

    We are retrieving data with third-party package SQL queries from a Citadel database. Certain queries for some object members will not return data, but the SQL search application software returns an "error". An analysis of the error from the SQL end does not find problem on SQL side. I suspect corruption of Citadel database. The link to database is good, as most tags do return a value as expected. 
    This problem occurred at the time of re-location of the database to a replacement computer.  Any ideas on how to fix such a problem?

    Can you give an example of the "bad" SQL statement and a good one?
    Ryan Shi
    National Instruments

  • Extracting SQL Queries from Crystal Reports

    I am trying to find a way or a utility to be able extract SQL queries from Crystal reports into a text file for documentation purposes.  These queries are not in the repository, they were entered into each of the reports when the reports were being built and I can't find a way to extract them.  Any ideas/suggestions?

    Hello,
    CR doesn't have the ability, and I don't recall if this has ever been asked previously. Great suggestion for the Idea Place tab in the up right corner of this page.
    If you find a developer it's quite simple to get:
                // log onto the server and then get the SQL.
                rptClientDoc.DatabaseController.LogonEx("van-w-13-dwilli", "xtreme", "sa", "pw");
                GroupPath gp = new GroupPath();
                string tmp = String.Empty;
                rptClientDoc.RowsetController.GetSQLStatement(gp, out tmp);
                // show the SQL but easy enough to save the SQL text to a file.
                MessageBox.Show(tmp, "Data Source Set and SQL Statement", MessageBoxButtons.OK, MessageBoxIcon.Information);
    Of course you need to open the report first, lots of samples on how to...
    Thank you
    Don

  • Want to practice SQL queries, do I need to download SQL editor

    Hi All,
    I have a doubt..
    I want to practice SQL queries. for this, do I need to download SQL editor and Intall or If I download any Oracle version, does it will have SQL editor? please anyone answer my question.

    I'm not sure how is it related to Peoplesoft, but if you installed an Oracle client on your client machine, then you have SQL*Plus or SQL Developer.
    Nicolas.

  • Create a VC Model for BEx queries with Cell Editor

    Hello All,
    I am trying to create a VC Model for BEx queries with Cell Editor.
    BW Development Team has created a BEX query with complex restrictions and calculations using Cell Editor feature of BI-BEX.
    The query output in BEx analyzer is correct where all values are being calculated at each Cell level and being displayed.
    But, while creating VC model, system is not displaying the Cells.Thus, no VC Model can be created.
    I have executed below steps:
    1. Created a VC Model for BEx Query - ZQRY_XYZ
    2. Create Iview -> Create a dataService -> Provide a Table from the Output
    In the Column field system is not showing any of the Cells (present in Cell Editor)
    Please help me to solve this issue.
    Thanks,
    Siva

    Hi
    If 'Cell Editor' is been used then that query must have the structure in it. You have to select that 'structure' object in your 'VC Table'.
    If you select that then you will get the required result in the output. This structure will be the structure where 'cell reference' is used in BI query, You have to select that structures name.
    Regards
    Sandeep

  • Want to execute SQL Queries from Textfile

    I have a text file full of a bunch of sql queries, of the format:
    select something1, something2
    from someplace
    select something3, something4
    from someplace2
    select something5, something6
    from someplace3
    I want to execute these queries one at a time and then after each one executes, I will do something with the resultset. Question is, how do I pull each query from the text file one at a time and execute? I was doing this by using java.util.Scanner and java.lang.StringBuilder where I would scan one line at a time and then check to see if the line is empty, otherwise I append the line to the StringBuilder. If the line is empty, I process whatever is stored in the StringBuilder. The problem with doing this is that it does not preserve the newline from the text file, so I get queries that look like:
    "select something5, something6from someplace3"
    which of course are invalid. Does anyone know a better way to build SQL queries / statements from a text file? How do I get the newline or carriage return character?

    Just replace newline by space?

  • How to find SQL queries from listerner log

    Hi,
    I have a question related to Oracle listener log. I've tried searching on this forum but couldn't find any threads on this
    Let me give a background on this. There are plenty of MSaccess databases which connect to Oracle database via ODBC link. I need to find out all the data items (Oracle tables / columns) that are referenced in the MS access applications. One way of doing that is open all MS access code components and look out for the ODBC links and extract the data items. This will be time consuming as there are several MS access databases (~450).
    I am wondering is there is way to find the data items from Oracle logs. The only information available to me now is the listener logs. A sample record id given below. Is there any way to obtain the SQL queries that was used from the lister log.
    08-MAR-2007 15:31:30 * (CONNECT_DATA=(SID=opr11a)(CID=(PROGRAM=MSACCESS.EXE)(HOST=PC12111)(USER=andrew.King))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.111.200.2)(PORT=1921)) * establish * opr11a * 0
    Any help in this regard is much appreciated
    Database version - Oracle 8i
    Thanks
    Moorthy
    Edited by: user8879184 on 20-Jul-2010 04:58

    user8879184 wrote:
    I need to find out all the data items (Oracle tables / columns) that are referenced in the MS access applications. I do not understand what you need. You want names of _"Oracle" tables/columns_ which refers MS Access *"Application"* ??

  • SQL Queries from Java to Access

    Does anyone know why it is that when i send a SQL query from a Java class to Access using the equals ( = ) function, it works fine, but when i send a query using the LIKE function, it does not work?
    If i manually copy and paste the LIKE query from Java into an Access query, the query works fine yet when i send it from the Java class, it does not work.
    An ideas would be most welcome

    Access uses a different token for the %-sign (a * I believe). When you want to do a 'like-query' through JDBC, you have to use the %-sign:
    LIKE '%text_to_search%'

  • RFC Error Received while opening queries from BEx Analiser

    Hi Friends,
    We have recently upgraded BW 3.5 to BI 7.0 and installed SAP GUI 710.
    When we try to open queries using old 3.5 BEx Analyser, we are getting error ' RFC Error Received '.
    strange thing is, it is not happening with all the users. For some users it is working fine and for some users they are getting this error only on first instance when they login after upgrade and this error is not comming from second time onwards with out implementing any corrective actions. Some users are still getiing this error even on second time when they login after upgrade.
    We are prety much confident that the authorisation is not an issue here.  Not sure about the GUI.
    Pls help me to understand the possible resons for this error and how we can fix it.
    Thanks,
    Nanvakanth

    Morning Experts,
    I have the same problem while opening the Query Designer or the WebApplicationDesigner in 3.5 or 7.0 it doesn`t matter....
    If I open a query with BEX and go to customize mode of the query --> the querydesigner will be open correctly --> very strange!
    Could anybody have a solution for this issue?
    Kind regards
    mrpynk
    Edited by: mrpynk on May 4, 2009 11:22 AM

  • Tracing SQL Queries from an Application.

    I read the info on here.
    http://www.psoug.org/reference/traceanalyzer.html_
    I have been able to use this guide to analyze traces.
    I installed DBMS_SUPPORT package on my XE database. I need to know, how can I run a trace from my front-end application and get it analyzed, using trace analyzer.
    I have got trace files, by using DBMS_SUpport. I have been successful in running tkprof on them.
    I need to trap the values of the bind variables that are being sent by the front-end application.
    Any suggestions would be welcome.
    Thanks.

    End to End Application Tracing can identify the source of an excessive workload, such as a high load SQL statement, by client identifier, service, module, action, session, instance, or an entire database. This isolates the problem to a specific user, service, session, or application component.
    Oracle provides the trcsess command-line utility that consolidates tracing information based on specific criteria.
    The SQL Trace facility and TKPROF are two basic performance diagnostic tools that can help you monitor applications running against the Oracle Server.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#i19083

  • Sql queries from internal tables based on context node

    Hi experts,
    I want to select from my inetrnal table which is based on the context node, the rows which do not appear in another internal table based on the context node.
    I have this data:
    data lt_item_level type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_item_level_cp type table of wd_this->element_item_level INITIAL SIZE 0.
    data lt_po_items TYPE table of wd_this->element_po_items INITIAL SIZE 0.
    I want to do this:
    select * into CORRESPONDING FIELDS OF TABLE lt_item_level_cp from lt_item_level WHERE lt_po_items-po_number NE lt_item_level-item_number.
    But i get an error:
    "LT_ITEM_LEVEL" is not defined in the ABAP Dictionary as a table,
    Is there a way to do it with select or should i loop over my internal tables?
    thank u very much!!

    hi,
    You cannot use Select queries on internal table.  do like this :
    loop at itab into wa where wa-F1 NE wa-F2.
    append wa to itab1.
    endloop.
    Here itab1 will have all the records as per your requiement.
    I hope it is clear.
    Edited by: Saurav Mago on Oct 26, 2009 5:37 PM

  • Retrieving SQL queries used in BO reports using BO Java SDKs

    Hi,
    Is it possible to retrieve SQL queries generated by Canned Reports? I have 200+ reports saved in my local system and i need to retrieve SQL queries from them, this is required for documentation purpose. Please let me know if it is possible thru BO java SDKs.

    This is the code I am using to retrieve the SQL values.
    IEnterpriseSession boEnterpriseSession = null;
                  boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( boUser, boPassword, boCmsName, boAuthType);
                   // Get the Report Application Factory service from Crystal Enterprise
                   IReportAppFactory rptAppFactory = (IReportAppFactory)boEnterpriseSession.getService("", "RASReportService");
                   // Get the InfoStore service from Crystal Enterprise
                   IInfoStore boInfoStore = (IInfoStore)boEnterpriseSession.getService("", "InfoStore");
                   // Retrieve the report by name from Crystal Enterprise
                   IInfoObjects boInfoObjects = boInfoStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '" + reportName + "'");
                   // Open the report into a Report Document object
                   ReportClientDocument rcd = rptAppFactory.openDocument((IInfoObject)boInfoObjects.get(0), 0, Locale.ENGLISH);
                   System.out.println("SQL query \n \n");
                   System.out.println(rcd.getRowsetController().getSQLStatement(null, ""));
    I am a newbie and I dont understand where the error lies.. Please help me out.
    regards,
    nitin
    When run the code gives  the following errors
    com.crystaldecisions.sdk.occa.managedreports.ras.internal.ManagedRASException: Cannot open report document. --- 0x80004005
    Unspecified error
    cause:com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: 0x80004005
    Unspecified error---- Error code:-2147467259 Error code name:failed
    detail: 0x80004005
    Unspecified error
         at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.openDocument(Unknown Source)
         at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.openDocument(Unknown Source)
         at com.hcl.BO.retrieveSql.RetrieveSQL.main(RetrieveSQL.java:44)
    Caused by: com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: 0x80004005
    Unspecified error---- Error code:-2147467259 Error code name:failed
         at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.s.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.if(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.if(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(Unknown Source)
         ... 4 more
    I am a newbie and

  • JComboBox Cell Editor in JTable

    I've scouered the forums for an answer to my question, and while
    finding other valuable advice, I have yet to find an answer to my
    question. But first, a little description:
    I have a JTable consisting of 5 columns:
    col1= standard Object cell editor
    col2= JComboBox cell editor
    col3= JComboBox cell editor, values dependent on col2
    col4= JComboBox cell editor, values dependent on col3
    col5= JComboBox cell editor, values dependent on col4
    Data structure looks like this:
    col1= company object, containing vector of values for col2
    col2= lease object, containing vector of values for col3
    col3= well object, containing vector of values for col4
    col4= pump object, containing vector of values for col5
    col5= simply displayed.
    I have a JButton that adds a new row to the table via dialog, then menu
    options to add entries to the comboboxes/vectors. The kicker here is
    that everything is fine up until I've added a pump, and click the cell
    to view the entry. In my cellEditor class, I have a 'getSelected()'
    method that returns 'combobox.getSelectedIndex()'. When 'edittingStopped()'
    is thrown for any cell in this column, I get a null pointer in my
    getSelectedIndex() method of the lease combobox - only in this pump
    column. Even the part column works correctly. Code snips:
    public class MyApplication ... {
      private TableColumn leaseColumn;
      private TableColumn wellColumn;
      private TableColumn pumpColumn;
      private TableColumn partColumn;
      private LeaseDropDown leaseDropDown;
      private WellDropDown wellDropDown;
      private PumpDropDown pumpDropDown;
      private PartDropDown partDropDown;
      private int currentLease = 0;
      private int currentWell = 0;
      private int currentPump = 0;
      public MyApplication() {
        leaseColumn = pumpshopTable.getColumnModel().getColumn(1);
        leaseDropDown = new LeaseDropDown(companies);
        leaseColumn.setCellEditor(leaseDropDown);
        DefaultTableCellRenderer leaseRenderer =
          new DefaultTableCellRenderer();
        leaseRenderer.setToolTipText("Click for leases");
        leaseColumn.setCellRenderer(leaseRenderer);
        //... same for lease, well, pump, part ...
        leaseDropDown.addCellEditorListener(new CellEditorListener() {
          public void editingCanceled(ChangeEvent e) {
          } // end editingCanceled method
          public void editingStopped(ChangeEvent e) {
            updateCells();
          } // end editingStopped method
        }); // end addCellEditorListener inner class
        //.... same inner class for well, pump, part ...
      } // end MyApplication constructor
      public void updateCells() {
        currentLease = leaseDropDown.getSelectedLease();
        //... get current well, pump, part ...
        leaseDropDown = new LeaseDropDown(companies); // companies=Vector,col1
        leaseColumn.setCellEditor(leaseDropDown);
        //... same for lease, well, pump and part columns ...
      } // end updateCells method
    } // end MyApplication class
    public class LeaseDropDown extends AbstractCellEditor
        implements TableCellEditor {
      private Vector companiesVector;
      private JComboBox leaseList;
      public LeaseDropDown(Vector cVector) {
        companiesVector = cVector;     
      } // end LeaseDropDown constructor
      public Component getTableCellEditorComponent(JTable table,
          Object value, boolean isSelected, int rowIndex, int vColIndex) {
        Company thisCompany = (Company) companiesVector.get(rowIndex);
        Vector leasesVector = (Vector) thisCompany.getLeases();
        leaseList = new JComboBox(leasesVector);
        return leaseList;
      } // end getTableCellEditorComponent method
      public Object getCellEditorValue() {
        return leaseList.getSelectedItem();
      } // end getCellEditorValue method
      public int getSelectedLease() {
        JOptionPane.showInputDialog("Selected lease is: " +
          leaseList.getSelectedIndex());
        return leaseList.getSelectedIndex();          
      } // end getSelectedLease method
    } // end LeaseDropDown class... LeaseDropDown can be extrapolated to well, pump, and part,
    handing well the selected lease, handing pump the selected
    lease and well, handing part the selected lease, well and pump.
    I guess my question is how do I get the selected comboboxitem (I'd
    settle for the entire combobox if there's no other way) to fill in the
    next column? Why does the way I have it now work for the first 2 combobox
    columns and not the third?

    I'll try to provide more details.
    I use a JComboBox implementation as a cell in a JTable. The CombBox is editable . This is what I get when I try to type in something.
    java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
    at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1507)
    at java.awt.Component.getLocationOnScreen(Component.java:1481)
    at javax.swing.JPopupMenu.show(JPopupMenu.java:921)
    at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:177)
    at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(BasicComboBoxUI.java:927)
    at javax.swing.JComboBox.setPopupVisible(JComboBox.java:790)
    at javax.swing.JComboBox.showPopup(JComboBox.java:775)
    I read some related bugs on the sun site but I am not sure if this is a bug and if it is then has it been fixed or work-around provided.
    any insights ??

  • Focus cell editor component of JTable when starting editing by typing

    Hello, everybody.
    We all know that the JTable component doesn't actually focus the actual cell editor component when editing is started by typing. But I need this functionality in an application of mine. So, I ask: is there a way to transfer focus to the editor component when editing is started by typing?
    Thank you.
    Marcos

    Well, I think that I've found it: JTable#setSurrendersFocusOnKeystroke.
    Marcos

  • SQL queries against a database view from an external system?

    Hi,
    I have a question about Database views in se11.
    Is it possible to create a database view and that do SQL queries against this  view from an
    external system, Not a SAP system?
    Please, I need you help.
    Best Regards
    Annika

    Hi Annika,
    it is possible , yes... but depends on your database systems in the SAP source DB and the external DB
    (easier if they are the same,  i.e. both ORACLE) - check out with your BASIS team (they have to create something like a "database link" in the external DB system  that you can use to access the tables in the SAP source).
    In the external DB you sure can create a view on these "remote" tables.
    We used this to pull data form SAP DB  to another DB system (both ORACLE based).
    But this is NOT supported by SAP , so be carefull. Below is the restriction for ORACLE (as well for other DB systems )
    see SAP note 581312 "Oracle database: licensing restrictions"
    As of point 3, it follows that direct access to the Oracle database is
    only allowed for tools from the areas of system administration and
    monitoring. If other software is used, the following actions, among
    other things, are therefore forbidden at database level:
    * Querying/changing/creating data in the database
    * Using ODBC or other SAP external access methods
    This means that additional application software is only allowed if this
    accesses the database through SAP interfaces (for example, RFC, SAP J2EE
    or BAPI).
    I would say if you KNOW the tables involved (using valid WHERE conditions and joins )
    and don't start queries from hell (ad-hoc type) wich can bring down your SAP system performance
    you can try it.
    But be warned...
    good luck...
    bye
    yk

Maybe you are looking for