Solved

Java Error

Posted on 2004-09-13
11
460 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
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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unix in java example 9 53
Arrays.asList  VS  ArrayList 4 45
Groovy problem when using SOAPUI : DispatchException occurred 7 27
expectj telnet failing 5 26
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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 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

17 Experts available now in Live!

Get 1:1 Help Now