Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Oracle Java thin client: security.Couldn't connect
Hi,
I'm trying to get around some Java Applet security restrictions.
I have enabled the "UniversalConnect" privilege with these results:
1)Netscape 3.0 - connection is made
2)Netscape 4.03/4.04 - errors below
security.Couldn't connect to '<remote-address>' with origin from
'<local-address>'.
local-address is something like "local-class-path"
3)Applet Viewer - connection is made
?
Any ideas why it won't work with 4.03/4.04?
Thanks,
Daniel
//--Start code--
/*
// Import the JDBC classes
import java.sql.*;
//import netscape.security.PrivilegeManager.*;
// Import the java classes used in applets
import java.awt.*; import java.io.*; import java.util.*;
public class jdbc2 extends java.applet.Applet
{
// The driver to load
static final String driver_class = "oracle.jdbc.driver.OracleDriver";
// The connect string
static final String connect_string =
"jdbc:oracle:thin:<id/password_at_url_address>:port:database_name";
// The query we will execute
static final String query = "select 'Hello JDBC: ' || sysdate from
dual";
// The button to push for executing the query Button execute_button;
// The place where to dump the query result TextArea output;
// The connection to the database
Connection conn;
// Create the User Interface
public void init ()
{
System.out.println("Hey I am in the init function\n");
try {
netscape.security.PrivilegeManager.enablePrivilege(
"UniversalConnect");
} catch (netscape.security.ForbiddenTargetException e) { // Failed because the privilege is forbidden
String property = "user.home"; try { String propertyValue = System.getProperty(property); } catch (netscape.security.AppletSecurityException f) { // Failed because the privilege has not been enabled System.out.println("Well Security not granted"); } }
// Do the work
public boolean action (Event ev, Object arg)
{
if (ev.target == execute_button)
{
try {
// See if we need to open the connection to the database
if (conn == null)
{
// Load the JDBC driver
output.appendText ("Loading JDBC driver " + driver_class + "\n");
Class.forName (driver_class);
// Connect to the databse
output.appendText ("Connecting to " + connect_string + "\n");
conn = DriverManager.getConnection (connect_string);
//CONNECTION ERROR RESULTS FROM LINE ABOVE
output.appendText ("Connected\n");
}
// Create a statement
Statement stmt = conn.createStatement ();
// Execute the query
output.appendText ("Executing query " + query + "\n");
ResultSet rset = stmt.executeQuery (query);
// Dump the result
while (rset.next ())
output.appendText (rset.getString (1) + "\n");
// We're done
output.appendText ("done.\n");
} catch (Exception e) {
} return true;