Solved

Java Error

Posted on 2004-09-13
11
458 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
  • 6
  • 5
11 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
It is an applet. How do I sign in?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
0
 
LVL 12

Author Comment

by:rcmb
Comment Utility
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
Comment Utility
are you loading the applet from a web server or directly from your local disk?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Author Comment

by:rcmb
Comment Utility
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
Comment Utility
can you post the code making the connection
0
 
LVL 12

Author Comment

by:rcmb
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No worries, let me know if you have any further problems.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now