Solved

Java Error

Posted on 2004-09-13
11
465 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

756 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