Probjems in communication with DB

Gintare Ragaisiene <[email protected]>
Newsgroups gmane.comp.cms.lenya.user
Message-ID <[email protected]>
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 :

public class EditNewsletters extends DocumentUsecase{
    private DataSourceComponent datasource;

    protected void initParameters() {
        super.initParameters();
    }


    protected void prepareView()throws Exception{
        super.prepareView();

        String view_already_prepared =
this.getParameterAsString("EditNewsletters.view_already_prepared");
        if(view_already_prepared == null){
            //this.manageDbData();
            this.testWithLmps();
            this.setParameter("EditNewsletters.view_already_prepared",
"true");
        }
    }

    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]')");

            String query = "SELECT * FROM area";
            ResultSet result = stmt.executeQuery(query);
            System.out.println("EditNewsletters result =
"+result.getFetchSize());

            stmt.close();
            myConnection.close();

        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ServiceException ex) {
            ex.printStackTrace();
        }
    }

    private void testWithLmps(){
        try {

            ServiceSelector selector = (ServiceSelector)
manager.lookup(DataSourceComponent.ROLE + "Selector");
            this.datasource = (DataSourceComponent) selector.select("lmps");
            Connection myConnection = this.datasource.getConnection();
            Statement stmt = myConnection.createStatement();

            String query = "INSERT INTO question VALUES (0,
'aaaaaaaaaaaaaa?')";
            stmt.execute(query);

            myConnection.close();

            System.out.println("EditNewsletters q = "+query);

         } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ServiceException ex) {
            ex.printStackTrace();
        }
    }


    protected void doExecute() throws Exception {
        super.doExecute();
        System.out.println("EditNewsletters doExecute()");
    }

}

in cocoon.xconf :

<jdbc logger="core.datasources.humana" name="humana">
        <pool-controller max="10" min="5"/>
        <auto-commit>false</auto-commit>

<dburl>jdbc:mysql://localhost:3306/humana?useUnicode=true&amp;characterEncoding=UTF-8</dburl>
        <user>root</user>
        <password>lau</password>
    </jdbc>


plz, help

thanks
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.