the problem here seems to be using the statement object twice without
closing the object

Statement stmt = myConnection.createStatement();

             stmt.execute("INSERT INTO email VALUES (0, '[email protected]
<mailto:[email protected]>')");

immediately after this line, there is a possibility that the transaction
is locked and hence the problem
I would suggest, close the connection  here

create a new statement and try this code and it should work

             String query = "SELECT * FROM area";
             ResultSet result = stmt.executeQuery(query);




On 27/01/10 16:11, Andreas Hartmann wrote:
> Am 27.01.10 16:35, schrieb Gintare Ragaisiene:
>> Hi,
>>
>>    I have problem with communication with my MySQL database. The problem
>> is no inserted records in the db after INSERT close executed. When I
>> connect with outside client to the same db and try to act it gives me
>> "Lock wait timetout exceeded; try restart transaction". I have code :
>>
>
>>      protected void manageDbData(){
>>          try {
>>              ServiceSelector selector = (ServiceSelector)
>> manager.lookup(DataSourceComponent.ROLE + "Selector");
>>              this.datasource = (DataSourceComponent)
>> selector.select("humana");
>>              Connection myConnection = this.datasource.getConnection();
>>              Statement stmt = myConnection.createStatement();
>>
>>              stmt.execute("INSERT INTO email VALUES (0, '[email protected]
>> <mailto:[email protected]>')");
>>
>>              String query = "SELECT * FROM area";
>>              ResultSet result = stmt.executeQuery(query);
>>              System.out.println("EditNewsletters result =
>> "+result.getFetchSize());
>
> Is this code executed?
>
>>
>>              stmt.close();
>>              myConnection.close();
>
> I'm not too familiar with JDBC, but I'd assume that the close()
> statements should go into the finally clause to avoid exhaustion of
> the connection pool if exceptions occur.
>
>
> BTW, your question is not really related to Lenya, maybe you get
> better hints on a more appropriate mailing list (e.g., on the Cocoon
> user list).
>
> -- Andreas
>
>


-- 
Vinod Kumar
Head of Development


FOR AND ON BEHALF OF: 

Technology Blueprint Ltd 
23 Clemens Street 
Royal Leamington Spa 
Warwickshire 
CV31 2DW 

T: 0845 004 7142 (Ext. 5200) 
E: [email protected]
W: www.propco.co.uk

The contents of this email are confidential and may be privileged, and 
are intended only for the use of the person or company named herein. Any 
views or opinions presented are solely those of the author and do not 
necessarily represent those of Technology Blueprint Limited. 

If you are not the intended recipient of this email or a person 
responsible for delivering it to the intended recipient, you are hereby 
notified that any distribution, copying or dissemination of the 
information herein is strictly prohibited



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to