Error accessing a JDBC Connection Object over a RMI Connection

Error accessing a JDBC Connection Object over a RMI Connection

Post by sergi.. » Sat, 31 Jul 1999 04:00:00



   Im having a problem... I did an app that connect a RMI Server and
call a method that returns a Connection Object (JDBC Connection). The
problem is that when I try to access remotely a method of the JDBC
Connection, an error of access denied occurs. Theres the error :

java.security.AccessControlException: access denied
(java.util.PropertyPermission file.encoding read)

Heres a Clients piece of code :

try  {
  myConnection = myInterface.getConnection(args[0],args[1],args[2]);
  Statement stmt = myConnection.createStatement();
  }
catch  (Exception e)  {}

   The error occurs when I call the getConnection method over the
myInterface object. In the Server app, the getConnection method is :

public Connection getConnection(String url, String login,
                                String password)  {
  Connection conexao = null;
  try  {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  }
  catch (ClassNotFoundException e01)  {
    System.out.println("Cant find JDBC Driver.");
  }
  try  {
    conexao = DriverManager.getConnection(url,login,password);
  }
  catch  (SQLException e02)  {
    System.out.println("SQL Connection Error.");
  }
  return conexao;

Quote:}

   Isnt possible to access a JDBC Connection Object over a RMI
Connection ?

   Thanks for any help...

Sergio Stateri Jr
System Analyses
Sao Paulo (SP) Brazil

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

Error accessing a JDBC Connection Object over a RMI Connection

Post by Joseph Weinstei » Sat, 31 Jul 1999 04:00:00


Nope. JDBC objects aren't serializable. They are (for type1,2,4 drivers)
just Java wrappers around a socket connection to the DBMS, which is
where you really made the JDBC connection.


>    Im having a problem... I did an app that connect a RMI Server and
> call a method that returns a Connection Object (JDBC Connection). The
> problem is that when I try to access remotely a method of the JDBC
> Connection, an error of access denied occurs. Theres the error :

> java.security.AccessControlException: access denied
> (java.util.PropertyPermission file.encoding read)

> Heres a Clients piece of code :

> try  {
>   myConnection = myInterface.getConnection(args[0],args[1],args[2]);
>   Statement stmt = myConnection.createStatement();
>   }
> catch  (Exception e)  {}

>    The error occurs when I call the getConnection method over the
> myInterface object. In the Server app, the getConnection method is :

> public Connection getConnection(String url, String login,
>                                 String password)  {
>   Connection conexao = null;
>   try  {
>     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>   }
>   catch (ClassNotFoundException e01)  {
>     System.out.println("Cant find JDBC Driver.");
>   }
>   try  {
>     conexao = DriverManager.getConnection(url,login,password);
>   }
>   catch  (SQLException e02)  {
>     System.out.println("SQL Connection Error.");
>   }
>   return conexao;
> }

>    Isnt possible to access a JDBC Connection Object over a RMI
> Connection ?

>    Thanks for any help...

> Sergio Stateri Jr
> System Analyses
> Sao Paulo (SP) Brazil

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

--
PS: Hey folks, we're hiring Java engineers for our WebLogic
    Engineering group in downtown S.F. Send me your resume.
--------------------------------------------------------------------------------
                    The Weblogic Application Server from BEA
         JavaWorld Editor's Choice Award: Best Web Application Server
  Java Developer's Journal Editor's Choice Award: Best Web Application Server
     Crossroads A-List Award: Rapid Application Development Tools for Java
Intelligent Enterprise RealWare: Best Application Using a Component Architecture
               http://weblogic.beasys.com/press/awards/index.htm

 
 
 

Error accessing a JDBC Connection Object over a RMI Connection

Post by Bret Ewi » Sat, 31 Jul 1999 04:00:00


Couldn't you implement a RemoteConnection class to forward requests to the real
Connection on the server-side? Obviously you'd have to wrap the other classes as
well (Statement, PreparedStatement, CallableStatement, ResultSet, etc...) Would this
be possible? If so, would this be useful? Can you think of other ways to solve this
problem?

Thanks,
Bret


> Nope. JDBC objects aren't serializable. They are (for type1,2,4 drivers)
> just Java wrappers around a socket connection to the DBMS, which is
> where you really made the JDBC connection.


> >    Im having a problem... I did an app that connect a RMI Server and
> > call a method that returns a Connection Object (JDBC Connection). The
> > problem is that when I try to access remotely a method of the JDBC
> > Connection, an error of access denied occurs. Theres the error :

> > java.security.AccessControlException: access denied
> > (java.util.PropertyPermission file.encoding read)

> > Heres a Clients piece of code :

> > try  {
> >   myConnection = myInterface.getConnection(args[0],args[1],args[2]);
> >   Statement stmt = myConnection.createStatement();
> >   }
> > catch  (Exception e)  {}

> >    The error occurs when I call the getConnection method over the
> > myInterface object. In the Server app, the getConnection method is :

> > public Connection getConnection(String url, String login,
> >                                 String password)  {
> >   Connection conexao = null;
> >   try  {
> >     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> >   }
> >   catch (ClassNotFoundException e01)  {
> >     System.out.println("Cant find JDBC Driver.");
> >   }
> >   try  {
> >     conexao = DriverManager.getConnection(url,login,password);
> >   }
> >   catch  (SQLException e02)  {
> >     System.out.println("SQL Connection Error.");
> >   }
> >   return conexao;
> > }

> >    Isnt possible to access a JDBC Connection Object over a RMI
> > Connection ?

> >    Thanks for any help...

> > Sergio Stateri Jr
> > System Analyses
> > Sao Paulo (SP) Brazil

> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.

> --
> PS: Hey folks, we're hiring Java engineers for our WebLogic
>     Engineering group in downtown S.F. Send me your resume.
> --------------------------------------------------------------------------------
>                     The Weblogic Application Server from BEA
>          JavaWorld Editor's Choice Award: Best Web Application Server
>   Java Developer's Journal Editor's Choice Award: Best Web Application Server
>      Crossroads A-List Award: Rapid Application Development Tools for Java
> Intelligent Enterprise RealWare: Best Application Using a Component Architecture
>                http://weblogic.beasys.com/press/awards/index.htm

 
 
 

Error accessing a JDBC Connection Object over a RMI Connection

Post by jon elli » Sat, 31 Jul 1999 04:00:00


Hi,

If you need to return a resultset via RMI you might want to look at
CachedRowSet. (on JDC)

j.


>    Im having a problem... I did an app that connect a RMI Server and
> call a method that returns a Connection Object (JDBC Connection). The
> problem is that when I try to access remotely a method of the JDBC
> Connection, an error of access denied occurs. Theres the error :

> java.security.AccessControlException: access denied
> (java.util.PropertyPermission file.encoding read)

> Heres a Clients piece of code :

> try  {
>   myConnection = myInterface.getConnection(args[0],args[1],args[2]);
>   Statement stmt = myConnection.createStatement();
>   }
> catch  (Exception e)  {}

>    The error occurs when I call the getConnection method over the
> myInterface object. In the Server app, the getConnection method is :

> public Connection getConnection(String url, String login,
>                                 String password)  {
>   Connection conexao = null;
>   try  {
>     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>   }
>   catch (ClassNotFoundException e01)  {
>     System.out.println("Cant find JDBC Driver.");
>   }
>   try  {
>     conexao = DriverManager.getConnection(url,login,password);
>   }
>   catch  (SQLException e02)  {
>     System.out.println("SQL Connection Error.");
>   }
>   return conexao;
> }

>    Isnt possible to access a JDBC Connection Object over a RMI
> Connection ?

>    Thanks for any help...

> Sergio Stateri Jr
> System Analyses
> Sao Paulo (SP) Brazil

> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

 
 
 

1. Connection Errors via ADO Connection Object

I recently changed this bit of code to add a record via the .addnew method.
I get a message that says "Run-time error '91': Object Variable or With
block variable not set."  when I hit debug it highlights the line "    Set
cmd.ActiveConnection = connSQL".  Any ideas would be greatly appreciated!
Thanks!!!

ABH

Private Sub Command1_Click()
    Dim connSQL As ADODB.Connection
    Dim strSQL As String
    Dim strConn As String
    Dim cmd As ADODB.Command
    Dim rsEmail As ADODB.Recordset

    Set connSQL = New ADODB.Connection
    Set cmd.ActiveConnection = connSQL
    cmd.CommandType = adCmdTable
    cmd.CommandText = "EmailData"
    Set rsEmail = cmd.Execute

    strConn = "Provider=sqloledb;Data Source=DEVELOPMENT\DEVTEST1;Initial
Catalog=EmailDB;User Id=EmailProcessor;Password=emailprocessor;"

    connSQL.ConnectionString = strConn
    connSQL.Open

    With rsEmail
        .AddNew

        !Subject = "Another Subject for 800 times"
        !received = "11/11/99"
        !Body = "blagh blagh blagh this is the body of the e-mail letter."
        !processed = "0"
        .Update
    End With

    'Cleanup Objects
    rsEmail.Close
    Set rsEmail = Nothing
    connSQL.Close
    Set connSQL = Nothing
    Set cmd = Nothing


'This is the body of the message', 1
End Sub

2. tables on CD

3. oracle jdbc thin driver (8.1.7) access via firewall - connection error

4. Joining Tooday!

5. JDBC connection- how to test a connection

6. How to retrieve a resultset from a system stored procedure

7. MySQL connection type jdbc connection refused, It used to work

8. NC-RALEIGH/DURHAM-90325--ORACLE-PowerBuilder-MS SQL Server-SYBASE-Systems Analyst

9. Please help: Oracle 7.1 JDBC connections : portmaper error/general connectivity errors

10. JDBC Connections / Connection Manager Problems...

11. Refused Connection - Oracle JDBC-Thin with Connection Manager

12. Refused Connection - JDBC Thin with Oracle Connection Manager

13. Please help: Oracle 7.1 JDBC connections : portmaper error/general connectivity errors