Link to home
Start Free TrialLog in
Avatar of KukiPei
KukiPei

asked on

Java applet and mysql connection problem

Hi to all.

I'm trying to connect my java applet with mysql on my local machine.
This is the code I'm using:

public class MySQLKonekcija
{

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

public MySQLKonekcija()
{
try
{
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver).newInstance();
}
catch( Exception e )
{
System.err.println( e );
}
}

public void ZakaciSe(String url, String korisnicko_ime, String lozinka)
{
try
{
/* Connection to database with default user and password*/
conn = DriverManager.getConnection(url, korisnicko_ime, lozinka);
stmt = conn.createStatement();
}
catch( Exception e )
{
System.err.println( e );
}
}
....
}

.
.
.
MySQLKonekcija connection = new MySQLKonekcija();
connection.ZakaciSe("jdbc:mysql://localhost/sah", "root", "");


When I start applet with appletviewer everything is OK,
bur when I start applet with browser (IE6) I get this error message:
"java.sql.SQLException: Cannot connect to MySQL server on localhost:3306.
Is there a MySQL server running on th machine/port you are trying to connect to?
(com.ms.security.SecurityExceptionEx)"

Does anybody know how to solve this problem and what I'm doing wrong.

Greetings!
SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aozarov
aozarov

Signing your applet can be another solution -> http://java.sun.com/developer/technicalArticles/Security/Signed/
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KukiPei

ASKER

Thanks to trying to help me.