Re: JDBC commit problem
- From: Robert Klemme <shortcutter@xxxxxxxxxxxxxx>
- Date: Tue, 12 Jun 2007 16:31:09 +0200
On 12.06.2007 16:14, mark wrote:
Hello,
I am working with MS Access database through JDBC. My application
allows to insert new data to the database and to view its contents.
The problem arises when I want to view my table just after inserting
new data, because then I do not see new row (but when I close and open
again the application, the new row exists... and just after inserting
when I open MS Access I also see it).
That's probably more of an Access issue than an JDBC issue.
My code:
// inserting new data
PreparedStatement stnt = conn.prepareStatement("INSERT INTO Addresses
(name, value, prize, date) VALUES (?,?,?,?)");
stnt.setString(1, name);
stnt.setDouble(2, value);
stnt.setDouble(3, prize);
stnt.setDate(4, sqlDate);
stnt.executeUpdate();
conn.commit();
stnt.close();
I'd swap the two lines above.
// viewing data
ResultSet rs = null;
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM Addresses");
while(rs.next()) {
// displaying
}
rs.close()
stmt.close();
Kind regards
robert
.
- References:
- JDBC commit problem
- From: mark
- JDBC commit problem
- Prev by Date: JDBC commit problem
- Next by Date: Database tool
- Previous by thread: JDBC commit problem
- Next by thread: Database tool
- Index(es):
Relevant Pages
|
|