Hello Pedro,

Increasing the connection timeout is not possible because other applications use these database too. I try'd to use C3Po but looks like the connections still timeout.

Here is an example

I have a remoting service. In the constructor I create my pool.

*Class.forName("com.mysql.jdbc.Driver");
String dbString = "jdbc:mysql://" + properties.getProperty("xxxxx") + ":3306/" + properties.getProperty("xxxxx"); DataSource unpooled = DataSources.unpooledDataSource(dbString,properties.getProperty("xxxx"),properties.getProperty("xxxxx"));
this.dataConnection = DataSources.pooledDataSource(unpooled);

*I have a method in the remoting class that get's some data from the database. When I call this method below from flex the first +- 10times it is not a problem but then I can't get any connection anymore and stops after "OPENING CONNECTION". Looks like there is something very wrong. Any idea? I just need that the connections stay open during the livecycle uptime.

*public String getTeaserUrl(String account)
{
System.out.println("#############REQUESTING TEASER####################\n\n");
try
{
System.out.println("OPENING CONNECTION\n");
Connection connect = this.dataConnection.getConnection();
System.out.println("GOT CONNECTION "+connect.toString());
String select = "SELECT FILENAME FROM TEASERS WHERE ACCOUNT = ? LIMIT 0,1";

PreparedStatement statement = connect.prepareStatement(select);
statement.setString(1,account);
ResultSet result = statement.executeQuery();

System.out.println("GOT TEASER RESULT!!!!!! "+result.toString());
while(result.next())
{
return "http://xxxxxxxxxxx/teasers/"+result.getString("FILENAME")+".flv";
}
connect.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
return "";
}

*Greets,
Ward*
*
Pedro Sena schreef:


1) Try to increase your connection timeout
2) Double check if you are releasing the connections correctly.
3) Use a connection pooling mechanism :) C3P0 is a good one and easy to use

If you are using hibernate, it will be very easy to configure it.

HTH

On Thu, Jun 18, 2009 at 2:11 PM, Ward Loockx <w...@loockx.be <mailto:w...@loockx.be>> wrote:



    Hello Pedro,


    Thanks for your reply!


    Here are the answers


    1) What is your connection timeout?
    -> connect timeout 5

    2) Are your application and database in the same machine?
    -> No (the DAO's make multiple connections to mysql servers and
    non of them are installed on the localhost)

    3) Are you using some kind of connection pool mechanism? If so,
    what are you
    using?
    -> Don't think so

    4) Is it ocurring when your execute some specific query or it occurs
    anytime?
    -> No, it just occurs after 20minutes. (every connection). So I
    get multiple errors in my application

    5) What engine are you using(MyISAM, InnoDB, ...) ?
    -> MyISAM


    Thanks,
    Ward



    On Thursday 18 June 2009 06:28:26 pm Pedro Sena wrote:
    > I had this problem before.
    >
    > It's related to mysql(obviously) not to flex, but I'll try to
    help you.
    >
    > To do that, please answer some questions:
    >
    > 1) What is your connection timeout?
    > 2) Are your application and database in the same machine?
    > 3) Are you using some kind of connection pool mechanism? If so,
    what are
    > you using?
    > 4) Is it ocurring when your execute some specific query or it occurs
    > anytime?
    > 5) What engine are you using(MyISAM, InnoDB, ...) ?
    >
    > PS
    >
    > On Thu, Jun 18, 2009 at 1:04 PM, Ward Loockx <w...@loockx.be
    <mailto:w...@loockx.be>> wrote:
    > > Hello,
    > >
    > > I'm having a problem with my connections to the mysql server
    that are
    > > timing out(and get the communicationsException). We use
    > > autoreconnect=true when creating the connections, the problem
    is that
    > > whole application is crashing at this point because the
    connection has
    > > been lost. The Dao's just create one connection at startup for all
    > > clients (that should stay open). Does somebody has experience
    with this
    > > problem or any advice how to keep the connections open?
    > >
    > > Here is the stacktrace
    > >
    > > com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
    Communications
    > > link failure
    > > Last packet sent to the server was 19 ms ago.
    > > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    > > Method)
    > > at
    > >
    > >
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAc
    > >cessorImpl.java:39) at
    > >
    > >
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConst
    > >ructorAccessorImpl.java:27) at
    > > java.lang.reflect.Constructor.newInstance(Constructor.java:513) at
    > > com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    > > at
    > >
    com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    > > at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3009)
    > > at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2895)
    > > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3438)
    > > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
    > > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
    > > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
    > > at
    > >
    > >
    com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1
    > >761) at

    > >
    com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1912
    > >) at
    > >
    > >
    com.dnxlive.cammer.remoting.CammerService.getShortcuts(CammerService.java
    > >:86) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    > > at
    > >
    > >
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
    > >:39) at
    > >
    > >
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
    > >mpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597)
    > > at
    > >
    > >
    flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.
    > >java:421) at
    > >
    > >
    flex.messaging.services.RemotingService.serviceMessage(RemotingService.ja
    > >va:183) at
    > >
    flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:150
    > >3) at

    > >
    > >
    flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint
    > >.java:884) at
    > >
    > >
    flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilt
    > >er.java:121) at
    > >
    flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
    > > at
    > >
    flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
    > > at
    > >
    > >
    flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter
    > >.java:67) at
    > >
    > >
    flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilt
    > >er.java:146) at
    > >
    > >
    flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:2
    > >78) at

    > >
    flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:322
    > >) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    > > at
    > >
    > >
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat
    > >ionFilterChain.java:290) at
    > >
    > >
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte
    > >rChain.java:206) at
    > >
    > >
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
    > >.java:233) at
    > >
    > >
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
    > >.java:191) at
    > >
    > >
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
    > >128) at
    > >
    > >
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
    > >102) at
    > >
    > >
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.j
    > >ava:109) at
    > >
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:28
    > >6) at

    > >
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845
    > >) at
    > >
    > >
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(H
    > >ttp11Protocol.java:583) at
    > >
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    > > at java.lang.Thread.run(Thread.java:619)
    > > Caused by: java.net.SocketException: Connection reset
    > > at java.net.SocketInputStream.read(SocketInputStream.java:168)
    > > at
    > >
    > >
    com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:1
    > >13) at
    > >
    > >
    com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecess


    > >ary(ReadAheadInputStream.java:160) at
    > >
    > >
    com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:1
    > >88) at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)

    > > at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2906)
    > > ... 36 more
    > >
    > > Thanks in advance!
    > > Ward Loockx





--
/**
* Pedro Sena
* Systems Architect
* Sun Certified Java Programmer
* Sun Certified Web Component Developer
*/

Reply via email to