Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2007

Tip: Looking for answers? Try searching our database.

JDBC commit problem

Thread view: 
mark - 12 Jun 2007 15:14 GMT
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).

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();

// viewing data
ResultSet rs = null;
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM Addresses");
while(rs.next()) {
   // displaying
}
rs.close()
stmt.close();

Any ideas??

Regards, mark
Robert Klemme - 12 Jun 2007 15:31 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> 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:
>
[quoted text clipped - 8 lines]
> conn.commit();
> stnt.close();

I'd swap the two lines above.

> // viewing data
> ResultSet rs = null;
[quoted text clipped - 5 lines]
> rs.close()
> stmt.close();

Kind regards

    robert


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.