my dog learned polymorphism*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "please I urgently need help" Watch "please I urgently need help" New topic
Author

please I urgently need help

Dan Dales
Greenhorn

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 {
Class.forName(driver);
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");
System.out.println(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)

** BEGIN NESTED EXCEPTION **

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

STACKTRACE:

java.net.SocketException: java.security.AccessControlException: access denied (j
ava.net.SocketPermission 127.0.0.1:3306 connect,resolve)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
va:143)
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
:411)
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)


** END NESTED EXCEPTION **


java.lang.NullPointerException
at aglettest.ContTest.onCreation(ContTest.java:50)
at com.ibm.aglets.SystemMessage.handle(Unknown Source)
at com.ibm.aglets.AgletThread.run(Unknown Source)
 
wood burning stoves
 
subject: please I urgently need help
 
Similar Threads
MySQL with Eclipse3.2
JDBC Connectivity problem
MySQl with Eclipse3.2
MYSql Driver ClassNotFound Exception
Applets + JDBC + MySQL = access denied