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).newI nstance();
}
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.getConnectio n(url, korisnicko_ime, lozinka);
stmt = conn.createStatement();
}
catch( Exception e )
{
System.err.println( e );
}
}
....
}
.
.
.
MySQLKonekcija connection = new MySQLKonekcija();
connection.ZakaciSe("jdbc: mysql://lo calhost/sa h", "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.SecurityE xceptionEx )"
Does anybody know how to solve this problem and what I'm doing wrong.
Greetings!
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).newI
}
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.getConnectio
stmt = conn.createStatement();
}
catch( Exception e )
{
System.err.println( e );
}
}
....
}
.
.
.
MySQLKonekcija connection = new MySQLKonekcija();
connection.ZakaciSe("jdbc:
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.SecurityE
Does anybody know how to solve this problem and what I'm doing wrong.
Greetings!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Signing your applet can be another solution -> http://java.sun.com/developer/technicalArticles/Security/Signed/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to trying to help me.