Solved

Java Error

Posted on 2004-09-13
11
468 Views
Last Modified: 2013-11-24
I am running SQL 2K (sp3a) on Win XP (sp2). Recently I started experiencing a problem when I attempt to access any pages that access the database.

I am using tomcat for my web services and eclipse 3 for my design sotware.

This is my specific error:

security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1433 connect,resolve)

I am slightly above Novice in this arena so as much detail as possible please.

Thanks,
RCMB
0
Comment
Question by:rcmb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12050029
is it an applet?

unsigned applets can only connect to the host they were loaded from
you'll need to sign it to get necessary permissions.
0
 
LVL 12

Author Comment

by:rcmb
ID: 12050054
It is an applet. How do I sign in?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12050063
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Author Comment

by:rcmb
ID: 12050097
This is somewhat strange as I have never had to sign in before and it was working just fine. The system is running on localhost port 8080 and was running just fine. I have made no changes to my system but it just stopped working.

RCMB
0
 
LVL 92

Expert Comment

by:objects
ID: 12050106
are you loading the applet from a web server or directly from your local disk?
0
 
LVL 12

Author Comment

by:rcmb
ID: 12050125
From a webserver. I have the tomcat plugin for eclipse, I start tomcat and then switch to my browser and open

http://localhost:8080/Administration/servlet/PersonnelAdmin

The servlet is in my web-inf file and it loads without problem. The page should be displaying a table with all personnel in the database. It only displays the top row of the table but no data.

The error above is what I see in my eclipse log.

Curtis
0
 
LVL 92

Expert Comment

by:objects
ID: 12050149
can you post the code making the connection
0
 
LVL 12

Author Comment

by:rcmb
ID: 12050184
This is the file I use to make my db connection with:

package mil.navy.snadis.securityservice.helper;

import java.sql.*;

public class ConnectionManager {

    // True if the database support transactions.
    private static boolean transactionsSupported = true;
    private static String driver = "net.sourceforge.jtds.jdbc.Driver";
    private static String url = "jdbc:jtds:sqlserver://localhost/Administration;TDS=7.0";
    private static String username = "sa";
    private static String password = "password";

    /**
     * Returns a database connection from the currently active connection
     * provider. (auto commit is set to true).
     */
   
    private void getConnectionstr(){
          
          //Properties  props = new Properties();
          
          if (ConnectionManager.transactionsSupported) {
                transactionsSupported = true;
      
          }else{
                transactionsSupported = false;
          }
          
    }
    public static Connection getConnection() throws Exception {
                 
        Connection tmpCon = null;
        Class driverClass = null;

System.err.println("driver is:" + driver);
System.err.println("url is:" + url);
System.err.println("username is:" + username);
System.err.println("password is:" + password);

        try {
            driverClass = Class.forName(driver);
        } catch (ClassNotFoundException ex) {
            System.err.println("Unable to get class:" + driver);
            throw ex;
        }
       
        try {
            DriverManager.registerDriver((Driver) driverClass.newInstance());
        } catch (Exception sqlex) {
                System.err.println("Unable to register driver " + driver);
                throw sqlex;
            }

        try {
            tmpCon = DriverManager.getConnection(url, username, password);
        } catch (SQLException sqlex) {
            System.err.println("Unable to get connection.");
            throw sqlex;
        }

        return tmpCon;
       
    }

    /**
     * Returns a Connection from the currently active connection provider that
     * is ready to participate in transactions (auto commit is set to false).
     */
    public static Connection getTransactionConnection() throws Exception {
          Connection tmpCon = getConnection();
          
          try {    
       
              if (isTransactionsSupported()) {
                  tmpCon.setAutoCommit(false);
              }
              
          }catch(Exception ex){
                throw ex;
          }

              return tmpCon;
    }

    /**
     * Closes a Connection. However, it first rolls back the transaction or
     * commits it depending on the value of <code>abortTransaction</code>.
     */
    public static void closeTransactionConnection(Connection conn, boolean abortTransaction) {
        // test to see if the connection passed in is null
        if (conn == null) {
            return;
        }
               
        // Rollback or commit the transaction
        if (isTransactionsSupported()) {
            try {
                if (abortTransaction) {
                    conn.rollback();
                }
                else {
                    conn.commit();
                }
            }
            catch (Exception e) {
            System.err.println(e);            
            }
        }
        try {
            // Reset the connection to auto-commit mode.
            if (isTransactionsSupported()) {
                conn.setAutoCommit(true);
            }
        }
        catch (Exception e) { System.err.println(e); }
        try {
            // Close the db connection.
            conn.close();
        }
        catch (Exception e) { System.err.println(e); }

    }

    public static boolean isTransactionsSupported() {
        return transactionsSupported;
    }

    public void setDriver (String inDriver) {
        driver = inDriver;
    }
    public void setDBUrl (String inUrl) {
        url = inUrl;
    }
    public void setDBUser (String inUser) {
        username = inUser;
    }
    public void setDBPassword (String inPassword) {
        password = inPassword;
    }
   
      /**
       *
       */
      public ConnectionManager() {            
            super();      
            getConnectionstr();
      }
}
0
 
LVL 92

Expert Comment

by:objects
ID: 12050232
Just as an aside, any reason why you're using an applet instead of an application?
Applications don't have any security restrictions like applets do.
0
 
LVL 12

Author Comment

by:rcmb
ID: 12050260
Just what was passed to me.

I did just switch back to my JBoss server and everything is working. There is obivously something wrong in my tomcat configuration.

I am going to turn this issue over to the people that set the server up last month.

Thanks for your help.

RCMB
0
 
LVL 92

Expert Comment

by:objects
ID: 12050461
No worries, let me know if you have any further problems.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question