Problem with actualization



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

.



Relevant Pages

  • Re: Sort in Query
    ... ASCII I assume) in the resultset of a query without a whereclause and the ... You are comparing *strings* not numbers. ... Senior Oracle DBA ...
    (comp.databases.oracle.server)
  • Re: NullPointerException error...
    ... On 20-2-2005 17:55, Frances Del Rio wrote: ... The ResultSet never got assigned with the result of the query (hence, ...
    (comp.lang.java.help)
  • Re: Problem with actualization
    ... database or database driver error. ... public static void executeQuery(String query) { ... Statement stmt; ... public static ResultSet getQueryResult{ ...
    (comp.lang.java.databases)
  • Re: data type error in my query
    ... the resultset returned the same value for comments. ... FROM dbo.tblWeblog as W1 LEFT OUTER JOIN dbo.tblUserComments as C ... > If blogID is a unique identifier for rows of tblWeblog, ... If I strip out W.blogComment the query runs fine. ...
    (microsoft.public.sqlserver.programming)
  • Re: When do selects execute for multiple resultsets
    ... SQL Server executes each query and stops when its ... When the first resultset is ... The CommandTimeout is measured from the time you execute the query until the ...
    (microsoft.public.dotnet.framework.adonet)