Problem with actualization
- From: "mark" <mkazmierski@xxxxxxxxx>
- Date: 13 Nov 2006 03:44:50 -0800
Hello,
I have such simple code:
Database.executeQuery("INSERT INTO Licence(LicenceNumber, LicenceCode)
VALUES ('" + l + "','" + c + "')");
ResultSet rs = Database.getQueryResult("SELECT * FROM Licence WHERE
LicenceNumber = '" + l + "' AND LicenceCode = '" + c + "'");
System.out.println("Number of rows = " + rs.getRow());
When I show these strings on the strings I got:
INSERT INTO Licence(LicenceNumber, LicenceCode) VALUES
('test','test123')
SELECT * FROM Licence WHERE (LicenceNumber = 'test' AND LicenceCode =
'test123')
Number of rows = 0
But when I look into database (MS Access) I see there that row.
Two above functions looks like that:
//------------------------------------------------------------------------------
public static void executeQuery(String query) {
Statement stmt;
try {
stmt = conn.createStatement();
stmt.executeUpdate( query );
stmt.close();
} catch (Exception e) {
e.printStackTrace();
}
}
//------------------------------------------------------------------------------
public static ResultSet getQueryResult(String query) {
Statement stmt;
try {
stmt = conn.createStatement();
ResultSet r = stmt.executeQuery( query );
return r;
} catch (Exception e) {
e.printStackTrace();
Error.getError(Error.DATABASE_READ_ERROR);
return null;
}
}
//------------------------------------------------------------------------------
p.s. I have also tried with conn.commit() but also with no success.
When I run the whole app again then I got correct results. Where is the
problem?!?
Best regards, mark
.
- Follow-Ups:
- Re: Problem with actualization
- From: timoi
- Re: Problem with actualization
- Prev by Date: Re: executeUpdate problem [newbie]
- Next by Date: Re: RMI and client JDBC
- Previous by thread: RMI and client JDBC
- Next by thread: Re: Problem with actualization
- Index(es):
Relevant Pages
|