-
JDBC Update Problems using PostgreSQL
I am doing some first tinkering with JDBC and PostgreSQL and I am stumped on
something.
I have a simple Java program that queries a table on the PostgreSQL
workstation successfully. I can iterate through the rows and display them.
However, when I try to update a value, like using:
ResultSet rs;
...
rs.updateInt("columnName", newIntVal);
The rs.updateInt() seems to succeed (no exceptions thrown), but the database
never gets changed. I am using JBuilder 4, and I *can* make changes to the
DB using the Data Explorer tool. So, the jdbc driver appears to be working.
FYI, my connection logic starts as follows:
...
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(
"jdbc dbc ostgresql", "myusername", "mypassword");
stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
res = stmt.executeQuery("SELECT * FROM customer FOR UPDATE");
...
Any ideas?
--
John McLaughlin
_______________________
johnm@oei.com
-
Re: JDBC Update Problems using PostgreSQL
The updateInt() method does succeed in what it is supposed to do, namely
updating the ResultSet. However if you want to propagate those changes to
the database, you need to call the updateRow() or insertRow() method.
PC2
"John McLaughlin" <johnm@oei.com> wrote in message
news:3bd05cd2@news.devx.com...
> I am doing some first tinkering with JDBC and PostgreSQL and I am stumped
on
> something.
>
> I have a simple Java program that queries a table on the PostgreSQL
> workstation successfully. I can iterate through the rows and display
them.
> However, when I try to update a value, like using:
> ResultSet rs;
> ...
> rs.updateInt("columnName", newIntVal);
>
> The rs.updateInt() seems to succeed (no exceptions thrown), but the
database
> never gets changed. I am using JBuilder 4, and I *can* make changes to
the
> DB using the Data Explorer tool. So, the jdbc driver appears to be
working.
>
> FYI, my connection logic starts as follows:
> ...
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> conn = DriverManager.getConnection(
> "jdbc dbc ostgresql", "myusername", "mypassword");
> stmt = conn.createStatement(
> ResultSet.TYPE_SCROLL_SENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
> res = stmt.executeQuery("SELECT * FROM customer FOR UPDATE");
> ...
>
> Any ideas?
>
> --
> John McLaughlin
> _______________________
> johnm@oei.com
>
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks