# ffmpeg rtmp authentication with SQL database

**URL:** https://community.wowza.com/t/ffmpeg-rtmp-authentication-with-sql-database/43491
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [February 27, 2015, 6:09pm UTC](https://community.wowza.com/t/ffmpeg-rtmp-authentication-with-sql-database/43491 "2015-02-27T18:09:43Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Andrey\_Litvinov](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@Andrey\_Litvinov](https://community.wowza.com/u/Andrey_Litvinov)
#### Post date: [March 2, 2015, 6:06pm UTC](https://community.wowza.com/t/ffmpeg-rtmp-authentication-with-sql-database/43491/6 "2015-03-02T18:06:01Z")

</div>

> Hi,
> 
> This [thread](http://community.wowza.com/t/-/37912) both reports and resolves a similar problem.
> 
> Basically the solution is to use [SecureURLParams](https://www.wowza.com/docs/how-to-secure-publishing-from-an-rtmp-encoder-that-does-not-support-authentication-modulesecureurlparams%28ModuleSecureURLParams%29), a different method of authentication.
> 
> Daren

No, no.

Standart authentication works fine. Add publisher via web interface and it works fine

```auto
ffmpeg rtmp://user:pass@ip/live/etc

```

But it doesn’t work for SQL authentication.

Here is my code sample

```auto
public void onConnect(IClient client, RequestFunction function,
			AMFDataList params) {
		getLogger().info("onConnect: DbAuth ");
		String userName = getParamString(params, PARAM1);
		String password = getParamString(params, PARAM2);
		getLogger().info("onConnect: param1 " +userName+ ", param2 "+password);
		
		Connection conn = null;
		try 
		{
			getLogger().info("onConnect: try ");
			conn = DriverManager.getConnection("jdbc:postgresql://localhost/pdb?user=puser&password=p1");
			Statement stmt = null;
			ResultSet rs = null;
			try 
			{
				getLogger().info("onConnect: connect ok ");
				stmt = conn.createStatement();
				rs = stmt.executeQuery("SELECT count(*) as userCount FROM users where login = '"+userName+"' and enc_password = '"+password+"'");
				if (rs.next() == true)
				{
					getLogger().info("onConnect: select ok ");
				    if (rs.getInt("userCount") > 0)
					{
						getLogger().info("onConnect: accept ok ");
						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());
	}

```

I got null, null for param1 and param2

---

_[View the full topic](https://community.wowza.com/t/ffmpeg-rtmp-authentication-with-sql-database/43491)._
