Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Remote Access to mySQL database

  Asked By: Clifford    Date: Dec 18    Category: Java    Views: 1153
  

Can anybody help me with the mysql server database?
I am doing a project which need a client and server. The server
(Operating System - Windows 2000 Advanced Server) will have mySQL
database install and running and together with IIS for the asp
pages. The client side will need to type the ip of the server and
access the asp pages. There will be a page with applet in which the
applet will retrieve data from the server mySQL database and display
on the applet. Well the applet cannot be start.

ERROR given by the applet is SQLException: Cannot connect to MySQL
server on host:3306. Is there a MySQL server running on the
machine/port you are trying to connect to?

Connection of the applet code:
String url = "jdbc:mysql:/localhost:3306/qti?username=&password=";
String query = "select * from class_actual where status = '1'";

try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
} catch(Exception ex)
{ setError("Can't find Database driver class: " + ex);
return;
}

try {
Vector results = new Vector();
Connection con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String a = rs.getString("happy");
String text7 = a;
results.addElement(text7);
}

stmt.close();
con.close();

setResults(results);

} catch(SQLException ex) {
setError("SQLException: " + ex);
}
}


I alsp creat a policy file as follow:
grant {
permission java.io.FilePermission "<<ALL FILES>>", "read, write,
delete, execute";
};

grant {
permission java.security.AllPermission;
};

grant {
permission java.net.NetPermission "setDefaultAuthenticator";
};

grant {
permission java.net.SocketPermission "server computer
name", "resolve";
permission java.net.SocketPermission "server IP:3306", "accept,
connect, listen, resolve";
};

grant {
permission java.lang.RuntimePermission "usePolicy";
};
and save it to the user profile setting. For example: C:\Documents
and Settings\Best PC\.java.policy and this file is put to both the
client and server.

The project is running smoothly in the server pc, either by IP or
local host. But the client side. All the asp pages work fine but
when it came to applet, it give the error. Please help me. I need to
show it to my teacher. I have tried to look into different ways but
to no clues. Can anybody give me some help, websites or anything so
that I can complete it in time for it to work on both server and
client.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Remote Access to mySQL database Or get search suggestion and latest updates.




Tagged: