Solved

Java Error

Posted on 2004-09-13
11
464 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTPSessionBindingListernter not configured in deployment descriptor 2 65
oracle 11g 23 107
How do I remove an object from a 3 40
jmss example java 2 23
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

856 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