Forums Register Login

please I urgently need help

+Pie Number of slices to send: Send
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)
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1218 times.
Similar Threads
MYSql Driver ClassNotFound Exception
MySQl with Eclipse3.2
MySQL with Eclipse3.2
Applets + JDBC + MySQL = access denied
JDBC Connectivity problem
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:10:17.