Database-connect within a JAR

Database-connect within a JAR

Post by Dirk Uebbe » Fri, 03 Jul 1998 04:00:00



Hello all,

I have a probem with connecting to an database in the case, that
my applet-class is packed in a JAR-archive. The same source-code,
not in a JAR-file, is running with no problems. But as I am putting
it into a JAR-archive, I am getting a message in the Netscape Java
Console, which look like this:

_________________________________________________________________________________________________
Netscape Communications Corporation -- Java 1.1.5
Type '?' for options.
Symantec Java! ByteCode Compiler Version 210.065
Copyright (C) 1996-97 Symantec Corporation
1
2
Hallo_2
netscape.security.AppletSecurityException: security.Couldn't connect to 'NTSV03' with origin from ''.
  at java.lang.Throwable.<init>(Compiled Code)
  at java.lang.Exception.<init>(Compiled Code)
  at java.lang.RuntimeException.<init>(Compiled Code)
  at java.lang.SecurityException.<init>(Compiled Code)
  at netscape.security.AppletSecurityException.<init>(Compiled Code)
  at netscape.security.AppletSecurityException.<init>(Compiled Code)
  at netscape.security.AppletSecurity.checkConnect(Compiled Code)
  at netscape.security.AppletSecurity.checkConnect(Compiled Code)
  at netscape.security.AppletSecurity.checkConnect(Compiled Code)
  at java.lang.SecurityManager.checkConnect(Compiled Code)
  at java.net.InetAddress.getAllByName0(Compiled Code)
  at java.net.InetAddress.getByName(Compiled Code)
  at java.net.Socket.<init>(Compiled Code)
  at oracle.sqlnet.SQLnet.Connect(Compiled Code)
  at oracle.sqlnet.SQLnet.Connect(Compiled Code)
  at oracle.sqlnet.SQLnet.Connect(Compiled Code)
  at oracle.jdbc.ttc7.TTC7Protocol.connect(Compiled Code)
  at oracle.jdbc.ttc7.TTC7Protocol.logon(Compiled Code)
  at oracle.jdbc.driver.OracleConnection.<init>(Compiled Code)
  at oracle.jdbc.driver.OracleDriver.connect(Compiled Code)
  at java.sql.DriverManager.getConnection(Compiled Code)
* at java.sql.DriverManager.getConnection(Compiled Code)
  at Haupt_applet.init(Compiled Code)
  at netscape.applet.DerivedAppletFrame$InitAppletEvent.dispatch(Compiled Code)
  at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
  at java.awt.EventDispatchThread.run(Compiled Code)
  at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
_________________________________________________________________________________________

The source-code of the applet look like this:

import java.applet.*;
import java.sql.*;
import java.awt.*;
import netscape.security.PrivilegeManager;

public class Haupt_applet extends Applet {

        public void init()
        {
            Connection con_to;
                Connection con_from;

                setLayout(null);
                setSize(232,172);
                setBackground(new Color(12632256));

        //      StDtVerwaltung StDtVerw = new StDtVerwaltung();

                try {
                    PrivilegeManager.enablePrivilege("UniversalConnect");

                    System.out.println("1");

                    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());

                    System.out.println("2");

est");

est");

                    con_to.setAutoCommit(false);

                    System.out.println("3");

        //          StDtVerw.Datenbank_anlegen(con_to);

                    System.out.println("4");

                    con_from.close();
                    con_to.close();
                    }

                    catch (netscape.security.ForbiddenTargetException e) {
                        System.out.println("Hello_1");
                    }

                    catch (java.lang.Exception ex) {
                        System.out.println("Hallo_2");
                        ex.printStackTrace();
                    }
        }

Quote:}

_________________________________________________________________________________________________

As you are able to see, I am using der Capability-class from Netscape, to get the
UniversalConnect-Privilege, which let me connect to the database server. But only, if I am not
putting my Applet in a JAR-archive!! And this is the problem.

I would be very glad, if you could help me please or if you could show me some place in WWW, where
I get help on this.

Waiting for your answer,

                Uebber

--

------------------------------------------------------------
Dirk Uebber                         phone: +49 7031 873 534
Sindelfingen                        fax  : +49 7031 873 535


------------------------------------------------------------

 
 
 

1. Connect to Oracle database from within VB

Hi there,

Does anybody know how to connect to an Oracle database from within a Visual
Basic executable ?
I have problems establishing this connection (I used to work with MS SQL).

Here is a description of the problem :

In the Oracle doc I find following info to connect to a database.  The
connection string should contain following parameters :
     DSN : The name of the data source.

     DBQ : An Oracle connect string.For more information, refer to the
SQL*Net documentation.

     UID : The user login ID.

     PWD : The user-specified password.

     ASY ON or OFF. This keyword will override the Asynchronous default you
had specified while setting up

So I tried in my VB program :

dim conn as ADODB.Connection

set conn = CreateObject("ADODB.Connection")

conn.Open "DSN=odbctest;DBQ=test.world;UID=guest;PWD=pipo;ASY=ON"

But no luck... doesn't work.

I have no problems to connect to MS SQL Server and to Access.  However my
connectionstring for Oracle doesn't seem to work.

Any ideas over there ?

Thanks for any reply

Dave

2. Phantom users

3. Using user's oracle credentials to connect to database within BMP

4. String processing changes in 11.5

5. Database applet and signed jar

6. SELECT TOP bug?

7. Can't connect to SQLServer using a dataSource within a Session bean

8. Hosting troubles

9. Possible to connect to ODBC within TSQL?

10. connecting to linked server from within trigger

11. connecting within a workgroup

12. Error connecting to SQL Server 7.0 from within a class