Re: JDBC commit problem



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
.



Relevant Pages

  • JDBC commit problem
    ... I am working with MS Access database through JDBC. ... The problem arises when I want to view my table just after inserting ... (name, value, prize, date) ...
    (comp.lang.java.databases)
  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... Dim Rng As Range ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... I have tried using the custom format, and you're right, it only ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • RE: Date/Time Strange Problem
    ... "Shapper" wrote: ... > I am having an error when inserting a record in an Access database. ... > I get the error "Data type mismatch in criteria expression." ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: OleDbDataAdapter question
    ... I would rather use a DataReader to read the records and at the same time ... inserting these records in the second DB. ... Ignacio Machin, ... > I want to copy some record from a Access database to another Access DB. ...
    (microsoft.public.dotnet.languages.csharp)