Past Single quote instead of double? But there's more - Mailing list pgsql-jdbc

From Oguz Imre
Subject Past Single quote instead of double? But there's more
Date
Msg-id 1D8A4BD6-5735-11D7-94F9-003065A215CC@comcast.net
Whole thread Raw
In response to Single quote instead of double?  (Oguz Imre <maccube@comcast.net>)
List pgsql-jdbc
Now I get the following error message. I display a table, then edit
one of the cells, so I update the row. Can anyone suggest What I am
doing wrong.

Thanks


=================

before edit

update site_sifre set username = "test this, too. Please!  " where
site_sifreid = "realOnePlayer            " and username = "test this,
too. Please!  " and sifre = "sekizlik       " and confirmdate =
"2003-03-14 19:18:50.319598"


after edit

update site_sifre set username = 'test this, too. Please!  ' where
site_sifreid = 'realOnePlayer            ' and username = 'test this,
too. Please!  ' and sifre = 'ssssssss       ' and confirmdate =
'2003-03-14 19:18:50.319598'

No results were returned by the query.

    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:157)

    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:141)

    at JDBCAdapter.setValueAt(JDBCAdapter.java:240)

    at TableSorter.setValueAt(TableSorter.java:278)

    at javax.swing.JTable.setValueAt(JTable.java:1783)

    at javax.swing.JTable.editingStopped(JTable.java:3129)

    at
javax.swing.AbstractCellEditor.fireEditingStopped(AbstractCellEditor.java:124)

    at
javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(DefaultCellEditor.java:328)

    at
javax.swing.DefaultCellEditor.stopCellEditing(DefaultCellEditor.java:213)

    at javax.swing.JTable$GenericEditor.stopCellEditing(JTable.java:3460)

    at
javax.swing.DefaultCellEditor$EditorDelegate.actionPerformed(DefaultCellEditor.java:345)

    at javax.swing.JTextField.fireActionPerformed(JTextField.java:489)

    at javax.swing.JTextField.postActionEvent(JTextField.java:670)

    at
javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:784)

    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1510)

    at javax.swing.JComponent.processKeyBinding(JComponent.java:2435)

    at javax.swing.JComponent.processKeyBindings(JComponent.java:2470)

    at javax.swing.JComponent.processKeyEvent(JComponent.java:2398)

    at java.awt.Component.processEvent(Component.java:4902)

    at java.awt.Container.processEvent(Container.java:1566)

    at java.awt.Component.dispatchEventImpl(Component.java:3598)

    at java.awt.Container.dispatchEventImpl(Container.java:1623)

    at java.awt.Component.dispatchEvent(Component.java:3439)

    at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1688)

    at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:593)

    at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:765)

    at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:698)

    at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:559)

    at java.awt.Component.dispatchEventImpl(Component.java:3468)

    at java.awt.Container.dispatchEventImpl(Container.java:1623)

    at java.awt.Window.dispatchEventImpl(Window.java:1585)

    at java.awt.Component.dispatchEvent(Component.java:3439)

    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)

    at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:230)

    at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:183)

    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)

    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

Update failed



On Saturday, March 15, 2003, at 01:28  PM, Oguz Imre wrote:


<excerpt>Gentle people,


When I run the following code, I get the resulting output which
PostgreSQL balks at. Is there a switch or something to yield single
quote? Kindly advise.


Code snippet: (from TableExample)


<fixed><color><param>0C0B,FFFE,3534</param>            String query =

                </color><color><param>F4F3,7978,9C9B</param>"update
site_sifre"</color><color><param>0C0B,FFFE,3534</param>+
//hard coded the tablename as String tableName =

                </color><color><param>F4F3,7978,9C9B</param>" set
"</color><color><param>0C0B,FFFE,3534</param>+columnName+</color><color><param>F4F3,7978,9C9B</param>"
= "</color><color><param>0C0B,FFFE,3534</param>+dbRepresentation(column,
value)+    //

</color><color><param>0C0A,FFFD,3533</param>metaData.getTableName(column</color><color><param>0000,0000,FFFD</param>+1</color><color><param>0C0A,FFFD,3533</param>);
returns "null"</color><color><param>0C0B,FFFE,3534</param>

                </color><color><param>F4F3,7978,9C9B</param>" where
"</color><color><param>0C0B,FFFE,3534</param>;

            </color><color><param>A5A4,1C1B,DCDB</param>// We don't
have a model of the schema so we don't know the</color><color><param>0C0B,FFFE,3534</param>

            </color><color><param>A5A4,1C1B,DCDB</param>// primary
keys or which columns to lock on. To demonstrate</color><color><param>0C0B,FFFE,3534</param>

            </color><color><param>A5A4,1C1B,DCDB</param>// that
editing is possible, we'll just lock on everything.</color><color><param>0C0B,FFFE,3534</param>



</color><color><param>FFFE,5E5D,CAC9</param>for</color><color><param>0C0B,FFFE,3534</param>(</color><color><param>FFFE,5E5D,CAC9</param>int</color><color><param>0C0B,FFFE,3534</param>
col =
</color><color><param>0000,0000,FFFE</param>0</color><color><param>0C0B,FFFE,3534</param>;
col<<getColumnCount(); col++) {

                String colName = getColumnName(col);


</color><color><param>FFFE,5E5D,CAC9</param>if</color><color><param>0C0B,FFFE,3534</param>
(colName.equals(</color><color><param>F4F3,7978,9C9B</param>""</color><color><param>0C0B,FFFE,3534</param>)){ 


</color><color><param>FFFE,5E5D,CAC9</param>continue</color><color><param>0C0B,FFFE,3534</param>;

                }


</color><color><param>FFFE,5E5D,CAC9</param>if</color><color><param>0C0B,FFFE,3534</param> (col
!=
</color><color><param>0000,0000,FFFE</param>0</color><color><param>0C0B,FFFE,3534</param>) {

                    query = query +
</color><color><param>F4F3,7978,9C9B</param>" and
"</color><color><param>0C0B,FFFE,3534</param>;

                }

                query = query + colName
+</color><color><param>F4F3,7978,9C9B</param>" =
"</color><color><param>0C0B,FFFE,3534</param>+

                    dbRepresentation(col, getValueAt(row, col));

                            }

            System.out.println(query);


</color><color><param>A5A4,1C1B,DCDB</param>//System.out.println("Not
sending update to database");</color><color><param>0C0B,FFFE,3534</param>

            statement.executeQuery(query);

        }


</color><color><param>FFFE,5E5D,CAC9</param>catch</color><color><param>0C0B,FFFE,3534</param> (SQLException
e) {

            e.printStackTrace();


System.err.println(</color><color><param>F4F3,7978,9C9B</param>"Update
failed"</color><color><param>0C0B,FFFE,3534</param>);

        }

        Vector dataRow = (Vector)rows.elementAt(row);

        dataRow.setElementAt(value, column);


    }


</color><color><param>00A1,0016,00E9</param>=====  OUTPUT ===

update site_sifre set username = "test this, too,again           "
where site_sifreid = "realOnePlayer            " and username = "test
this, too           " and sifre = "ssssssss       " and confirmdate =
"2003-03-14 19:18:50.319598"

java.sql.SQLException: ERROR:  Attribute "test this, too,again
" not found


    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)

.

.

.


If I replace the double quote with single and run this update in the
SQL Commander window of DbVisualizer, it works fine.


Table is:


create table site_sifre(

site_sifreid char(25),

userName char(25),

sifre char(15),

confirmDate timestamp

);



Using:


JDK 1.4.1

Mac OSX, 10.2.4

PostgreSQL 7.3

PostgreSQL Native Driver

PostgreSQL 7.3.1 JDBC2 jdbc driver build 107


DbVisualizer gives in depth info regarding Database, and what setting
are. Too lengthy to include here, but here are a few:


Attribute

-----------------------------------    --------

.

.

storesUpperCaseQuotedIdentifiers    false

storesLowerCaseQuotedIdentifiers    false

storesMixedCaseQuotedIdentifiers    false

getIdentifierQuoteString        "

getSearchStringEscape            \

.

.</color></fixed> </excerpt>
Now I get the following error message. I display a table, then edit one
of the cells, so I update the row. Can anyone suggest What I am doing
wrong.
Thanks

=================
before edit
update site_sifre set username = "test this, too. Please!  " where
site_sifreid = "realOnePlayer            " and username = "test this,
too. Please!  " and sifre = "sekizlik       " and confirmdate =
"2003-03-14 19:18:50.319598"

after edit
update site_sifre set username = 'test this, too. Please!  ' where
site_sifreid = 'realOnePlayer            ' and username = 'test this,
too. Please!  ' and sifre = 'ssssssss       ' and confirmdate =
'2003-03-14 19:18:50.319598'
No results were returned by the query.
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1St
atement.java:157)
    at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1St
atement.java:141)
    at JDBCAdapter.setValueAt(JDBCAdapter.java:240)
    at TableSorter.setValueAt(TableSorter.java:278)
    at javax.swing.JTable.setValueAt(JTable.java:1783)
    at javax.swing.JTable.editingStopped(JTable.java:3129)
    at
javax.swing.AbstractCellEditor.fireEditingStopped(AbstractCellEditor.jav
a:124)
    at
javax.swing.DefaultCellEditor$EditorDelegate.stopCellEditing(DefaultCell
Editor.java:328)
    at
javax.swing.DefaultCellEditor.stopCellEditing(DefaultCellEditor.java:213
)
    at javax.swing.JTable$GenericEditor.stopCellEditing(JTable.java:3460)
    at
javax.swing.DefaultCellEditor$EditorDelegate.actionPerformed(DefaultCell
Editor.java:345)
    at javax.swing.JTextField.fireActionPerformed(JTextField.java:489)
    at javax.swing.JTextField.postActionEvent(JTextField.java:670)
    at
javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:784)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1510)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2435)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2470)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2398)
    at java.awt.Component.processEvent(Component.java:4902)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3598)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:
1688)
    at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFoc
usManager.java:593)
    at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboard
FocusManager.java:765)
    at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboard
FocusManager.java:698)
    at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusM
anager.java:559)
    at java.awt.Component.dispatchEventImpl(Component.java:3468)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Window.dispatchEventImpl(Window.java:1585)
    at java.awt.Component.dispatchEvent(Component.java:3439)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea
d.java:230)
    at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
java:183)
    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
Update failed


On Saturday, March 15, 2003, at 01:28  PM, Oguz Imre wrote:

> Gentle people,
>
> When I run the following code, I get the resulting output which
> PostgreSQL balks at. Is there a switch or something to yield single
> quote? Kindly advise.
>
> Code snippet: (from TableExample)
>
>             String query =
>                 "update site_sifre"+
>       //hard coded the tablename as String tableName =
>                 " set "+columnName+" = "+dbRepresentation(column,
> value)+    // metaData.getTableName(column+1); returns "null"
>                 " where ";
>             // We don't have a model of the schema so we don't know the
>             // primary keys or which columns to lock on. To demonstrate
>             // that editing is possible, we'll just lock on everything.
>             for(int col = 0; col<getColumnCount(); col++) {
>                 String colName = getColumnName(col);
>                 if (colName.equals("")) {
>                     continue;
>                 }
>                 if (col != 0) {
>                     query = query + " and ";
>                 }
>                 query = query + colName +" = "+
>                     dbRepresentation(col, getValueAt(row, col));
>                             }
>             System.out.println(query);
>             //System.out.println("Not sending update to database");
>             statement.executeQuery(query);
>         }
>         catch (SQLException e) {
>             e.printStackTrace();
>             System.err.println("Update failed");
>         }
>         Vector dataRow = (Vector)rows.elementAt(row);
>         dataRow.setElementAt(value, column);
>
>     }
>
> =====  OUTPUT ===
> update site_sifre set username = "test this, too,again           "
> where site_sifreid = "realOnePlayer            " and username = "test
> this, too           " and sifre = "ssssssss       " and confirmdate =
> "2003-03-14 19:18:50.319598"
> java.sql.SQLException: ERROR:  Attribute "test this, too,again
>   " not found
>
>     at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:131)
> .
> .
> .
>
> If I replace the double quote with single and run this update in the
> SQL Commander window of DbVisualizer, it works fine.
>
> Table is:
>
> create table site_sifre(
> site_sifreid char(25),
> userName char(25),
> sifre char(15),
> confirmDate timestamp
> );
>
>
> Using:
>
> JDK 1.4.1
> Mac OSX, 10.2.4
> PostgreSQL 7.3
> PostgreSQL Native Driver
> PostgreSQL 7.3.1 JDBC2 jdbc driver build 107
>
> DbVisualizer gives in depth info regarding Database, and what setting
> are. Too lengthy to include here, but here are a few:
>
> Attribute
> -----------------------------------    --------
> .
> .
> storesUpperCaseQuotedIdentifiers    false
> storesLowerCaseQuotedIdentifiers    false
> storesMixedCaseQuotedIdentifiers    false
> getIdentifierQuoteString        "
> getSearchStringEscape            \
> .
> .

pgsql-jdbc by date:

Previous
From: Oguz Imre
Date:
Subject: Re: Single quote instead of double?
Next
From: "Michael Paesold"
Date:
Subject: Re: Past Single quote instead of double? But there's more