Version: 2.0.0

Dated: 08/10/2012

SwingSet

 

 

Introduction
News
CVS
Java Docs
Screen Shots / Demo
Download
Links
FAQ
Contact Us
License

 

FAQ

1.  I am trying to run the samples. I see "Processing....." and nothing
    happens.  What is wrong?

    You might be missing one or more required jar files.  Please make sure
    that you have the following jar files:
        1. Latest SwingSet binary jar file (e.g. swingset-bin_0.8.0_beta.jar)
        2. Latest PostgreSQL JDBC drive (e.g. pg74.214.jdbc3.jar) from:
           http://jdbc.postgresql.org/download.html
        3. For JDK/JRE prior to 1.5, early RowSet implementation (e.g.
           rowset.jar) from:
           http://java.sun.com/developer/earlyAccess/jdbc/jdbc-rowset.html

    If you still have problems:
        1. Unzip the demo jar file and extract the files to a folder.
        2. From a command prompt go to that folder and type:
            java  MainClass
        3. You will now see any remaining errors on the command prompt screen.


2.  I have set the headers for a SSDataGrid, so why I don't see them on the
    screen?

    You have to set the headers before you set the rowset. If you reverse the
    order, you will not see the headers.  If you want to specify headers, use
    the empty constructor.


3.  Why am I getting an exception, while setting the renderers.

    You have to set the renderer only after you have set the rowset.  Until
    you set the rowset the JTable does not have any columns, so when you try
    to set a renderer SSDataGrid tries to access the specified column from
    JTable, which causes an exception.


4.  What happens to my default values and any other custom settings when I
    change my underlying rowset?

    All the defaults and other information like headers, renderer will remain
    the same even after changing the rowset for a SSDataGrid. If you want to
    change any settings or remove the defaults and/or headers, you have to
    call the setXXXXX() functions to change the behavior.

    Example: You have a rowset for a SSDataGrid and have set the default value
             for the third column to be "XYZ". If you then change the query
             for the rowset and want to remove the defaults for the SSDataGrid,
             you have to call the setDefaultValues() method like this:
                 dataGrid.setDefaultValues(null,null);

             This will remove all the default values used.

5.  I setup a SSDataGrid based on a rowset querying columns "X," "Y," and "Z."
    I made a small change to the underlying query but return the same set of
    columns.  Why are my renderers and/or hidden columns not working as
    expected?

    When modifying a query for a SSDataGrid's rowset, you must insure that the
    columns are returned in the same order!  When you set a renderer, or
    specify a column as hidden you specify either a column number or column
    name (in which case SwingSet internally converts the name to a column
    number).  If you change the column ordering for the underlying query and
    apply the modified rowset to your SSDataGrid, SwingSet continues to use
    the "old" column numbers for any renderers or hidden columns.  You will
    have to supply new renderers/hidden columns for the reordered columns.


6. I'm having trouble getting SwingSet to work with MySQL.  Are there any
   special instructions?

    Yes.  The mysql-connector-java MySQL driver has a unique ResultSet
    implementation. The default ResultSet is not updatable so an
    UpdatableResultSet is needed for creating updatable GUI's with SwingSet.
    Rather than creating a RowSet using a connection string and query,
    the developer should instantiate their RowSet with an UpdatableResultSet.

    In addition, since there is no connection  string or query, the
    SSDataNavigator needs to be explicitly told not to call the execute()
    method of RowSet and to assume that the RowSet already contains the query
    results.  This is done with the setCallExecute() method.

    Example:
        Let rs be your UpdatableResultSet object.
        JdbcRowSetImpl rowset = new JdbcRowSetImpl(rs);
        SSDataNavigator dataNavigator = new SSDataNavigator();
        dataNavigator.setCallExecute(false);
        dataNavigator.setRowSet(rowset);

        If you want to change the query, change the rs object as needed,
        re-instantiate your RowSet, and re-call the setRowSet method of your
        SSDataNavigator.

    (P.S.: This is a work around provided for MySQL DB users based on the
     feedback from lopes. See
     http://sourceforge.net/forum/forum.php?thread_id=1005899&forum_id=313186)

7. I'm currently using a SwingSet release prior to 0.9.0.  What is this new
   SSConnection and SSRowSet?  How do I fix my programs?

   For version 0.9.0 a datasource abstraction layer was added to SwingSet. All
   of the SwingSet components are now based on a new SSRowSet interface rather
   than Sun's existing RowSet interface.  The SSRowSet differs from RowSet in
   two important ways:
     1. SSRowSet extends serializable which greatly facilitates serialization/
        deserialization in the rest of the SwingSet components
     2. SSRowSet only contains methods necessary to support the data types in
        used by SSTextDocument which will make writing SSRowSet implementations
        for non-updatable RowSets and other non-database datasources (e.g. a
        HashMap) much easier

   A SSJdbcRowSetImpl implementation of SSRowSet is provided to replace the
   JdbcRowSetImpl used in most existing SwingSet applications.  It is basically
   a serialized wrapper of JdbcRowSetImpl.  It can be used in conjunction with
   the new SSConnection, a serialized wrapper of the Connection interface, which
   handles serialization/deserialization of database connection info (path,
   username, password, etc.).  Finally, an SSRowSetAdapter is provided with
   empty method implementations of everything in SSRowSet.  This adapter can be
   easily extended with non-empty method implementations for non-database
   datasources.

   To accommodate non-updatable RowSets, SSJdbcRowSetImpl can be extended with
   custom updateXYZ() methods to handle database updates via INSERT/UPDATE
   queries. SSJdbcRowSetImpl can also serve as a template for writing SSRowSet
   wrappers for other RowSets (e.g. CachedRowSet, WebRowSet, etc.).

   Unfortunately, the introduction of the SSRowSet requires modification of
   existing SwingSet applications, but with the SSJdbcRowSetImpl and
   SSConnection, these changes should be minimal. Below is an example of changes
   required to transition to 0.9.0 and later versions of SwingSet:

    ***********************
    OLD - Connection/RowSet
    ***********************
    import java.sql.*;
    import com.sun.rowset.JdbcRowSetImpl;

    Connection conn = null;
    JdbcRowSetImpl rowset = null;

    Class.forName("org.postgresql.Driver");
    conn = DriverManager.getConnection
        ("jdbc:postgresql://pgserver.greatmindsworking.com/suppliers_and_parts",
        "swingset","test");
    rowset = new JdbcRowSetImpl(conn);

    ***************************
    NEW - SSConnection/SSRowSet
    ***************************
    import java.sql.*;  // still needed
    import com.nqadmin.swingSet.datasources.SSJdbcRowSetImpl;
    import com.nqadmin.swingSet.datasources.SSConnection;

    SSConnection ssConnection = null;
    SSJdbcRowSetImpl rowset = null;

    ssConnection = new SSConnection
        ("jdbc:postgresql://pgserver.greatmindsworking.com/suppliers_and_parts",
        "swingset", "test");
    ssConnection.setDriverName("org.postgresql.Driver");
    ssConnection.createConnection();
    rowset = new SSJdbcRowSetImpl(ssConnection);

8. I'm building some screens graphically in NetBeans using the SwingSet
   JavaBeans.  I've setup my SSConnection and SSRowSet properly, but when I
   launch the screen, I'm getting null pointer exceptions on the bind() methods
   of the individual SwingSet components?  How do I correct this?

   When building an application in NetBeans you have to call the execute()
   method explicitly on SSJdbcRowSetImpl. This has to be done in the post
   initialization code for the last rowset/connection property you set.

   Assuming that you are setting the four connection-related properties for
   SSConnection followed by the two connection-related properties for
   SSJdbcRowSetImpl, you would put the following code in the post initialization
   code for the last property set for SSJdbcRowSetImpl:

    // ASSUMING THAT THE ROWSET VARIABLE NAME IS sSJdbcRowSetImpl1
        try {
            sSJdbcRowSetImpl1.execute();
        } catch(SQLException se) {
            se.printStackTrace();
        }

   Note that in NetBeans you should add your SSConnection and SSJdbcRowSetImpl,
   set their properties, and add the above call to execute() before adding and
   binding individual SwingSet components to SSRowSet column names.


SourceForge.net Logo