Thank you for your answer Luiz , But why i can't do directly a connexion to Mysql throw Application adaptater to catch connexion from rtmp protocol, i use "the public boolean appConnect( IConnection conn , Object[] params )" in order to accept deny or control rtmp connection to my application.
Regards Yann. ----- Original Message ----- From: "Luiz Filipe" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Sunday, June 24, 2007 12:36 AM Subject: [Red5] RES: : Registered connection param in a mysql database > Yann, the best approach is to create a connection pool and the get a > connection from the dataSource from your ApplicationAdapter. > > In your red5-web.xml create a xml entry like this: > > <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" > destroy-method="close"> > <property name="driverClassName" > value="com.mysql.jdbc.Driver" /> > <property name="url" > value="jdbc:mysql://YOUR_IP:3306/DATA_BASE_NAME?autoReconnect=true" /> > <property name="username" value="DB_USER_NAME" /> > <property name="password" value="DB_PASS" /> > <property name="maxActive" value="40" /> > <property name="maxIdle" value="20" /> > <property name="maxWait" value="10000" /> > </bean> > > Inside the ApplicatoinAdapter create an attribute named dataSource > (DataSource) with set and get methods. > Then you?ll be able to get a connection from the pool using the dataSource > object. > > Regards, > > Luiz Filipe. > > -----Mensagem original----- > De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] nome de > [EMAIL PROTECTED] > Enviada em: sexta-feira, 22 de junho de 2007 14:19 > Para: [email protected] > Assunto: [Red5] : Registered connection param in a mysql database > > > Hi all , i am a beginner in java , and i don't manage to do a mysql > connection with red5 on a debian etch, please can you give me a clue :) > > My test : > Here is a simple application to test "ApplicationAdapter" , the method : > "public boolean appConnect( IConnection conn , Object[] params )" > refused the connection if i don't put the true param in > the_nc.connect("rtmp://stream.hpifrance.com/myTest",true); so it works but > nothing is > loggued in my mysql database ... > > If someone can help me , i desperate about this > > > //source code : Application.java > > package org.red5.server.webapp.myTest; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.red5.server.api.IConnection; > import org.red5.server.adapter.ApplicationAdapter; > import org.red5.server.api.IScope; > import org.red5.server.api.IClient; > import org.red5.server.api.stream.ISubscriberStream; > import org.red5.server.api.service.IServiceCapableConnection; > import org.red5.server.api.scheduling.IScheduledJob; > import org.red5.server.api.scheduling.ISchedulingService; > import java.util.Map; > import java.util.Vector; > import java.util.Iterator; > import org.red5.io.utils.ObjectMap; > import java.sql.*; > > > public class Application extends ApplicationAdapter > { > > static > { > try > { > Class.forName("com.mysql.jdbc.Driver"); > } > catch ( ClassNotFoundException exception ) > { > log.error( "ClassNotFoundException " + exception.getMessage( ) ); > } > } > > > public boolean appStart ( ) > { > log.info( "Red5First.appStart" ); > return true; > } > public void appStop ( ) > { > log.info( "Red5First.appStop" ); > } > public boolean appConnect( IConnection conn , Object[] params ) > { > log.info( "Red5First.appConnect " + conn.getClient().getId() ); > boolean accept = (Boolean)params[0]; > > > try{ > > Connection connexion = > DriverManager.getConnection("jdbc:mysql://127.0.0.1/red5","red5","supervisor > red5"); > > Map properties = conn.getConnectParams(); > //connection time > Long stamp = System.currentTimeMillis( ); > // client ip > String ip = (String)conn.getRemoteAddress( ); > // agent > String agent = (String)properties.get( "flashVer" ); > // referrer > String referrer = (String)properties.get( "swfUrl" ); > > Statement sttmnt = connexion.createStatement( ); > String insert = "INSERT INTO " > + "`test`.`red5first_users` " > + > "(`counter`,`ip`,`referrer`,`flashversion`,`connection`)" > + "VALUES(NULL,'" + ip + "','" + referrer + "','" + > agent > + "','" + stamp + "')"; > // execute query > sttmnt.executeUpdate( insert ); > } > catch ( SQLException exception ) > { > log.error( "SQLException at appConnect: " + > exception.getMessage( ) ); > } > > > > if ( !accept ) rejectClient( "you passed false..." ); > return true; > } > > public void appDisconnect( IConnection conn , Object[] params ) > { > log.info( "Red5First.appDisconnect " + conn.getClient().getId() ); > } > > > } > > //end source code > > /////////////compilation ok > javac -classpath > /usr/lib/red5/lib/mysql-connector-java-5.0.6-bin.jar:/usr/lib/red5/red5.jar > Application.java > no error > /////////////jar ok > jar -cfv myTest.jar > no error > > but when i connect with rtmp://stream.hpifrance.com/myTest > > nothing is log in Mysql :( > > Best regard . > > > _______________________________________________ > Red5 mailing list > [email protected] > http://osflash.org/mailman/listinfo/red5_osflash.org > > > _______________________________________________ > Red5 mailing list > [email protected] > http://osflash.org/mailman/listinfo/red5_osflash.org _______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org
