I am having difficulties writing java program using JConnector drivers:

import java.sql.*;

public class Connect
{
public static void main (String[] args)
{
Connection conn = null;

try
{
String userName = "username";
String password = "pass";
String url = "jdbc:mysql://mysql/db_name";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}

I think code is written rigth, but it doesn't connect to MySQL. I am running over ssh.
I can connect to MySQL via ssh, and this program I run also by ssh, so I use localhost.
What is wrong here?

sorry for my bad english.