learn java
The moose likes Other Open Source Projects and the fly likes please I urgently need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "please I urgently need help" Watch "please I urgently need help" New topic

please I urgently need help

Dan Dales

Joined: Jul 20, 2011
Posts: 8
Hello all,

Am trying to query mysql data base using an aglet.
At compilation, there is no error but each time load it to tahiti server
the error below keep coming up at the console.

Please can some one help me out. Time is no longer on my side.

I need it to work so that I can move on with my project

Thanks in anticipation.

The code is as follows:
package aglettest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import com.ibm.aglet.*;

public class ContTest extends Aglet{

//static String url = "jdbc:mysql://localhost:3306/pos?user=root&password=daniel";
static String driver = "org.gjt.mm.mysql.Driver";
static String user = "root";
static String pw = "daniel";
static Statement stmt;
static Connection con;

// public Engine() {

//Establish connection to database
public static Statement getConnected() {
try {
try {
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pos?user=root&password=daniel");
stmt = con.createStatement();
} catch (SQLException ex) {
//JOptionPane.showMessageDialog(null, "Problem loading driver\n" + ex.getMessage());
System.out.println("Problem loading driver\n" + ex.getMessage());
} catch (Exception ex2) {
JOptionPane.showMessageDialog(null, "Problem establishing connection\n" + ex2.getMessage());

return stmt;

public void onCreation(Object o){
String role;

String st="SELECT * FROM `role`";

stmt = getConnected();
try {
ResultSet rs = stmt.executeQuery(st);

while (rs.next()) {
role = rs.getString("role");

}catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Problem executing Query\n" + ex.getMessage());


The error message that keep coming up is:
Problem loading driver
Unable to connect to any hosts due to exception: java.net.SocketException: java.
security.AccessControlException: access denied (java.net.SocketPermission 127.0.
0.1:3306 connect,resolve)


MESSAGE: java.security.AccessControlException: access denied (java.net.SocketPer
mission connect,resolve)


java.net.SocketException: java.security.AccessControlException: access denied (j
ava.net.SocketPermission connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:225)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1805)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at aglettest.ContTest.getConnected(ContTest.java:30)
at aglettest.ContTest.onCreation(ContTest.java:48)
at com.ibm.aglets.SystemMessage.handle(Unknown Source)
at com.ibm.aglets.AgletThread.run(Unknown Source)


at aglettest.ContTest.onCreation(ContTest.java:50)
at com.ibm.aglets.SystemMessage.handle(Unknown Source)
at com.ibm.aglets.AgletThread.run(Unknown Source)
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: please I urgently need help