Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 4th, 2004, 12:14 PM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Database connection issue...

I have been writing a distributed application in Java. Originally, the code used to access a remote database from a client machine using JDBC to retrieve data. I tried to implement the database access in RMI, i.e. there is one DatabaseManager object that is running on the server that controls access to the database. However, I have been unsuccessful in getting the program to work using RMI. When I run the program on the server, I get the following messages:

-------------------------------------------------------------------------------------------------------------------
root@server:~# java entnet.server.DatabaseManager
Unable to connect to database at present. Click "OK" to return to main menu.
java.sql.SQLException: Unable to connect to any hosts due to exception: java.security.AccessCont********************ception: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
ComputeEngine exception: java.security.AccessCont********************ception: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
root@server:~# java entnet.server.DatabaseManager
Unable to connect to database at present. Click "OK" to return to main menu.
java.sql.SQLException: Unable to connect to any hosts due to exception: java.security.AccessCont********************ception: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)
DatabaseManager exception: java.security.AccessCont********************ception: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
-------------------------------------------------------------------------------------------------------------------

The first error is the DatabaseManager object attempting to connect to the local database. Obviously, it's access has been denied. This only happened when I tried to access the database locally, I was able to connect to the database fine from a remote machine.
The second error is java trying to register my remote class with the rmiregistry.

I am not too sure, but I think that what I need is to create a custom policy file that grants access to these interfaces and ports. Can somebody give me a little help as I have not had any previous experience dealing with Java's security mechanism. Am I correct about the policy file? If so, how to I specify to the JVM that it should use the new policy file?

Any help will be most appreciated.

Thank you.

Peter Green.

 
Old February 4th, 2004, 06:24 PM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I managed to overcome the above problem, but now when my program tries to connect to the database, the following exception is thrown:

java.sql.SQLException: Unable to connect to any hosts due to exception: java.security.AccessCont********************ception: access denied (java.util.PropertyPermission file.encoding read)

This is produced by this connect statement:

con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/media", "mysql", "mysql");

What I don't understand is that a remote machine can access the database using a connection statement like:

con = DriverManager.getConnection("jdbc:mysql://server:3306/media", "mysql", "mysql");

But the JDBC doesn't seem to be able to connect locally.

Thanks in advance

Pete.

PS. I am using a mysql database with the mysql jdbc connector.
 
Old April 5th, 2004, 08:59 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Azrael,

did you managed your problem ? I have the same problem and I'd know how to fix it.can you give me some helpful advice.

Thank you

christian felix






Similar Threads
Thread Thread Starter Forum Replies Last Post
Oracle connection issue. rupen ASP.NET 2.0 Professional 2 March 11th, 2009 02:26 AM
Chapter 11 Connection Issue justin000 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 August 4th, 2008 06:14 AM
ODBC Connection Issue On Client Site prince500 SQL Server 2005 1 June 7th, 2007 02:03 PM
CONNECTION ISSUE ktracy_2k SQL Server 2000 4 December 1st, 2006 04:45 PM
php/sql connection issue m3rajk PHP Databases 2 August 19th, 2003 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.