I downloaded the JDBC driver from mysql from here:
http://dev.mysql.com/downloads/connector/j/5.0.html
Unzip and driver archive and drop the driver mysql-connector-java-5.0.5-bin.jar into the Wowza Pro lib folder [install-dir]/lib.
The serverside Java code would look something like this:
package com.mycompany.wms.dbtest;
import java.sql.*;
import com.wowza.wms.application.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
public class DBTest extends ModuleBase
{
static public void onConnect(IClient client, RequestFunction function,
AMFDataList params)
{
String userName = getParamString(params, PARAM1);
String password = getParamString(params, PARAM2);
// preload the driver class
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception e)
{
getLogger().error("Error loading: com.mysql.jdbc.Driver: "+e.toString());
}
Connection conn = null;
try
{
conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=monty&password=greatsqldb");
Statement stmt = null;
ResultSet rs = null;
try
{
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT count(*) as userCount FROM users where username = '"+userName+"' and password = '"+password+"'");
if (rs.next() == true)
{
if (rs.getInt("userCount") > 0)
{
client.acceptConnection();
}
}
}
catch (SQLException sqlEx)
{
getLogger().error("sqlexecuteException: " + sqlEx.toString());
}
finally
{
// it is a good idea to release
// resources in a finally{} block
// in reverse-order of their creation
// if they are no-longer needed
if (rs != null)
{
try
{
rs.close();
}
catch (SQLException sqlEx)
{
rs = null;
}
}
if (stmt != null)
{
try
{
stmt.close();
}
catch (SQLException sqlEx)
{
stmt = null;
}
}
}
conn.close();
}
catch (SQLException ex)
{
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
getLogger().info("onConnect: " + client.getClientId());
}
static public void onConnectAccept(IClient client)
{
getLogger().info("onConnectAccept: " + client.getClientId());
}
static public void onConnectReject(IClient client)
{
getLogger().info("onConnectReject: " + client.getClientId());
}
static public void onDisconnect(IClient client)
{
getLogger().info("onDisconnect: " + client.getClientId());
}
}
Then edit your Application.xml and add a reference to this new module to the section and set Connections/AutoAccept to false.
Charlie