Skip site navigation (1) Skip section navigation (2)

Problem Retrieving/Refresing Data From Database

From: "Jeanna Geier" <jgeier(at)apt-cafm(dot)com>
To: "Pgsql-Jdbc(at)Postgresql(dot)Org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Problem Retrieving/Refresing Data From Database
Date: 2007-01-15 16:36:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Hello List!

I've been working on an issue and have it almost working -- going to need
some help to troubleshoot this one!  Our program connects to the database
and depending on the view/table that the user selects to view, pops up a
table with that information in it.

For example, click on a room in a blueprint, select 'Measurement' to attach
and the 'measurment' data from the database for that room is displayed.  The
box in which this is displayed has a drop-down box in three of the columns,
allowing the user to select whether to view the data in 'feet' (the
default), 'meters', 'yards', etc...

My problem is, that when the user tries to select a different unit of
measure than the default (feet), the box defauts back to feet and does not
allow the user to view the data in any other measurement.

Here's my CREATE VIEW for the 'measurement' table:

CREATE OR REPLACE VIEW elementdata.measurement AS
 SELECT e.elementid, da.projectname, da.square_unit AS square_unit_sq,
a.area * su.units_per_sqfoot AS area_sq, e.slope AS slope_inches,
sa.slopearea * cu.units_per_cufoot AS slopearea_sq, da.linear_unit AS
linear_unit_lin, p.perimeter * lu.units_per_foot::double precision AS
perimeter_lin, da.cubic_unit AS cubic_unit_cu, e.height * lu.units_per_foot
AS height_lin, e.height::double precision * a.area * cu.units_per_cufoot AS
volume_cu, da.drawingid
   FROM (( SELECT perimeter.elementid, perimeter.perimeter
           FROM elementdata.perimeter
         SELECT length.elementid, length.length AS perimeter
           FROM elementdata.length)
         SELECT circumference.elementid, circumference.circumference AS
           FROM elementdata.circumference) p
   LEFT JOIN elementdata.area a USING (elementid)
   LEFT JOIN element e USING (elementid)
   LEFT JOIN elementdata.slopearea sa USING (elementid)
   JOIN layer la USING (layerid)
   JOIN drawing da USING (drawingid)
   JOIN globaldata.linear_units lu USING (linear_unit)
   JOIN globaldata.square_units su USING (square_unit)
   JOIN globaldata.cubic_units cu USING (cubic_unit);


CREATE RULE delete_measurement AS ON DELETE
	TO elementdata.measurement
	DO INSTEAD UPDATE element SET height = 0 WHERE (element.elementid =

In my code, I'm checking to see if the check-box is checked to attach this
information, if so, attach it to the drawing it is displayed on; I also have
a method for chkAttachMsrmntActionPerformed:

private void addTables(String schema) throws SQLException{
        APTListModel listModel = (APTListModel)list.getModel();

        Vector usedTables = null;

        int type = -1;
            type = APTListModel.DATA_TABLE;
            usedTables = aptElement.getTableNames(schema,

            //**01/13/07 - JG Added statment to check if 'Measurement' is
added to Model
            //If checkbox checked, add it; if not, delete it
            if (chkAttachMsrmnt.isSelected() &&
            } else{

        else if(schema.equals("region")){
            type = APTListModel.REGION_TABLE;
            usedTables = aptElement.getTableNames(schema,
        else if(schema.equals("projectdata")){
            Project project = main.getProject();
            type = APTListModel.PROJECT_TABLE;
            usedTables = project.getTableNames(main.getConnection());

        //add tables and capitialize first letter
        ListIterator li = usedTables.listIterator();
            String nextTable = (String);
            nextTable = nextTable.substring(0,1).toUpperCase() +
            listModel.addElement(nextTable, type);

I think the code is all right, but I'm just a bit confused as to why you
cannot select any other unit of measure from the box??

Thoughts and comments would be greatly appreciated!!  Thanks for your time
and help!


pgsql-jdbc by date

Next:From: Kris JurkaDate: 2007-01-15 17:30:36
Subject: Re: "nested transaction" - encosing statement gets closed
Previous:From: Havard TveiteDate: 2007-01-15 13:11:12
Subject: "nested transaction" - encosing statement gets closed when the enclosed statement is closed

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group