• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet connects through JDBC to mSQL DB server

 
Hieroni Friscus
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I'm writing an applet which connects to the mSQL database server.
The applet loads the jdbc driver without problems.
But when I try to make a connection I get the following error message :

java.security.AccessControlException : access denied (java.util.PropertyPermission imaginary.msql-jdbc.logging read).

Does anybody knows how to solve this?
Here is the code for my applet :
-----------------------------------------------------------------

import java.sql.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Vector;

public class DbApplet extends Applet {

private Statement stat;
private Button b1;
private String message = "Alles Ok";
private String message2, message3;
private int x, y;
private Vector results;

public void init () {
x = 5;
y = 90;
b1 = new Button("Search");
b1.addActionListener(new ClickHandler());
add(b1);
try {
Class.forName("com.imaginary.sql.msql.MsqlDriver").newInstance();
System.out.println("Driver loaded");
message = "Driver loaded";
repaint();
}
catch (Exception e) {
System.out.println("Driver not loaded");
e.printStackTrace();
message = "Driver not loaded";
repaint();
}
}

public void start() {
String url = "jdbc:msql://Jerry:1114/TestDB";
String query = "Select * from Contact";
try {
Connection conn = DriverManager.getConnection(url);
stat = conn.createStatement();
ResultSet rs = stat.executeQuery(query);
while (rs.next()) {
String voor = rs.getString(1);
String achter = rs.getString(2);
String tekst = voor + " " + achter;
results.addElement(tekst);
}
}
catch (Exception e) {
e.printStackTrace();
message2 = "connection error";
repaint();
}
}

public void paint (Graphics g) {
g.drawString(message, 5, 50);
if (message2 != null) {
g.drawString(message2, 5, 70);
}
if (message3 != null) {
g.drawString(message2, x, y);
}
}

class ClickHandler implements ActionListener {
public void actionPerformed (ActionEvent e) {
int index = 1;
message3 = results.elementAt(index).toString();
repaint();
}
}
}
---------------------------------------------------------------

I installed a desktop webserver and connect with my laptop to my desktop (which is called Jerry), so according to me the url string is correct : "jdbc:msql://Jerry:1114/TestDB"
my desktop is ofcourse running also the mSQL DB server (TestDB is the DB and Contact is the only table in this DB).

I did the same thing by using an application instead of an applet and then it works fine.

I would be extremely thankfull if anyone could help me solving this issue.

Hieroni
------------------
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hieroni,
Do you want to use the applet localy or remotely (which is to say do
you want the database to be on the same computer as is running the applet)?
 
Hieroni Friscus
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
The purpose is to use the applet remotely.
Normally, signing the applet isn't necessary because i connect to the same server as where I downloaded the applet from.
Hieroni
 
Paul Bailey
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you figure this out? sorry, i just found this thread again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic