Issue is solved, there was needed myConnection.commit() . Thanks everybody
for help, here's the code :
private void testWithLmps(){
Connection myConnection = null;
try {
ServiceSelector selector = (ServiceSelector)
manager.lookup(DataSourceComponent.ROLE + "Selector");
this.datasource = (DataSourceComponent) selector.select("lmps");
myConnection = this.datasource.getConnection();
Statement stmt = myConnection.createStatement();
String query = "INSERT INTO question VALUES (0,
'aaaaaaaaaaaaaa?')";
stmt.execute(query);
System.out.println("EditNewsletters q = "+query);
myConnection.commit();// because auto-commit=false
} catch (SQLException ex) {
ex.printStackTrace();
} catch (ServiceException ex) {
ex.printStackTrace();
}finally{
if(myConnection != null){
try {
myConnection.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
Gintare
On Thu, Jan 28, 2010 at 9:49 AM, Gintare Ragaisiene <
[email protected]> wrote:
> o, I forgot to mention, I did restart of mysql server and lenya server.
>
>
> On Thu, Jan 28, 2010 at 9:48 AM, Gintare Ragaisiene <
> [email protected]> wrote:
>
>> ok, now my code looks like this:
>>
>> But the problem remains the same, no inserted records, and the same
>> timeout transaction error message after outside client interaction with db.
>>
>>
>> private void testWithLmps(){
>>
>> Connection myConnection = null;
>>
>> try {
>>
>> ServiceSelector selector = (ServiceSelector)
>> manager.lookup(DataSourceComponent.ROLE + "Selector");
>> this.datasource = (DataSourceComponent)
>> selector.select("lmps");
>>
>> myConnection = this.datasource.getConnection();
>> Statement stmt = myConnection.createStatement();
>>
>> String query = "INSERT INTO question VALUES (0,
>> 'aaaaaaaaaaaaaa?')";
>> stmt.execute(query);
>>
>>
>> System.out.println("EditNewsletters q = "+query);
>>
>> } catch (SQLException ex) {
>> ex.printStackTrace();
>> } catch (ServiceException ex) {
>> ex.printStackTrace();
>> }finally{
>> if(myConnection != null){
>> try {
>>
>> myConnection.close();
>> } catch (SQLException ex) {
>> ex.printStackTrace();
>> }
>> }
>> }
>> }
>>
>>
>>
>> On Wed, Jan 27, 2010 at 10:33 PM, Michael Wechner <
>> [email protected]> wrote:
>>
>>> 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.
>>>>
>>>
>>> I can confirm this. You really need to make sure that every connection is
>>> being closed no matter what exception happened during the connection,
>>> because otherwise your system will be "blocked" quickly
>>>
>>> Cheers
>>>
>>> Michael
>>>
>>>
>>>>
>>>> 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
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>