[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Applet unable to access DB

I was having problem with database access from applet. So, some one asked me to sign the jar files. I did sign them now. The applet now shows some different exceptions. The exceptions are

java.lang.ExceptionInInitializerError
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:229)
at Panel3D.<init>(Panel3D.java:41)
at Panel2D.startAccess(Panel2D.java:106)
at Panel2D.<init>(Panel2D.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.applet.AppletSecurity.checkAccess(Unknown Source)
at java.lang.ThreadGroup.checkAccess(Unknown Source)
at java.lang.ThreadGroup.getParent(Unknown Source)
at javax.media.j3d.MasterControl$34.run(MasterControl.java:3522)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.MasterControl.<clinit>(MasterControl.java:3515)
... 15 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Please let me know if any one has any idea about the same. Thank you very much.
0
Joegal
Asked:
Joegal
  • 3
  • 2
1 Solution
 
CEHJCommented:
You have to sign *all* jars involved
0
 
JoegalAuthor Commented:
Code:


Panel2D.java is a JApplet program.


import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import visual2D.RecursiveResult;
//import visual3D.*;

public class Panel2D extends JApplet implements ActionListener, MouseListener
{
      
      private RecursiveResult imagePanel;
      private JPanel menuPanel;
      private JPanel linkPanel;
    private JScrollPane srollPane;
    private JPanel imageContainer;
    private JLabel zoomedInfo;
    private JLabel linkLabel, depthLabel, weightLabel;
    private JButton zoomInButton;
    private JButton zoomOutButton;
    private JButton originalButton;
    private JButton showLinks;
      private JPanel mainPanel;
        private JButton zoomIn;
        private JButton zoomOut;
        private JButton original;
        private JTextField linkText, weightText;
        private JButton links;
        private JComboBox depth;
        private Color bGColor;
        String string=" ",previousString;
        Dimension size;
        //Dimension minSize=this.getSize();
       String[] depthValues = {"1", "2", "3", "4", "5"};
        public void init()
        {
              //WindowUtilities.setNativeLookAndFeel();
              /*startAccess();
        }
        
        public Panel2D()
        {
              //super("Web Link Visualization");
              startAccess();
        }
        
        public void startAccess()
        {        */
        
              menuPanel = new JPanel();
          mainPanel = new JPanel();
          linkPanel = new JPanel();
          bGColor=Color.gray;
          mainPanel.setBackground(bGColor);
          menuPanel.setLayout(new GridLayout(2,1));
          linkPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
          mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
            //mainPanel.add(m);
            linkLabel = new JLabel("Enter Link");
            linkPanel.add(linkLabel);
            linkPanel.setBackground(bGColor);
            linkPanel.setPreferredSize(new Dimension(50,200));
            linkText = new JTextField("http://www.usm.edu/index.html",30);
            linkText.addActionListener(this);
            linkPanel.add(linkText);
      
            links = new JButton("View");
            links.setBackground(bGColor);
            links.setFont(new Font("Arial", Font.BOLD, 14));
            links.setToolTipText("View Graphical Representation of Web Link Structure");
            links.addActionListener(this);
            linkPanel.add(links);

            //mainPanel.add(createMenubar(bGColor));
            showLinks = new JButton("Links");
            showLinks.setBackground(bGColor);
            showLinks.setFont(new Font("Arial", Font.BOLD, 14));
            showLinks.setToolTipText("To View the URL");
            showLinks.setBorder(BorderFactory.createBevelBorder(1));
            //showLinks.hide();
            showLinks.addActionListener(this);
            mainPanel.add(showLinks);
            
            //Icon zoomInButton = new ImageIcon("Images/ZoomIn24.gif");
            zoomIn = new JButton("Zoom In");//zoomInButton);
            zoomIn.setBackground(bGColor);
            zoomIn.setBorder(BorderFactory.createBevelBorder(0));
            zoomIn.setToolTipText("Zoom In");
            zoomIn.addActionListener(this);
            mainPanel.add(zoomIn);
            
            //Icon zoomOutButton = new ImageIcon("Images/ZoomOut24.gif");
            zoomOut = new JButton("Zoom Out");//zoomOutButton);
            zoomOut.setBackground(bGColor);
            zoomOut.setBorder(BorderFactory.createEtchedBorder(0, Color.red/*highlight*/, Color.lightGray
/*shadow*/));
            zoomOut.setToolTipText("Zoom Out");
            zoomOut.addActionListener(this);
            mainPanel.add(zoomOut);
            
            //Icon originalButton = new ImageIcon("Images/Zoom24.gif");
            original = new JButton("Original");//originalButton);
            original.setBackground(bGColor);
            original.setBorder(BorderFactory.createMatteBorder(2/*top*/, 2/*left*/, 2 /*bottom*/, 2
/*right*/, Color.lightGray));
            original.setToolTipText("Original Size");
            original.addActionListener(this);
            mainPanel.add(original);
            
            depthLabel = new JLabel("Depth");
            mainPanel.add(depthLabel);
            depth = new JComboBox(depthValues);
            depth.setSelectedIndex(0);
            depth.setBackground(bGColor);
            depth.addActionListener(this);
            mainPanel.add(depth);
            
            weightLabel = new JLabel("Weight");
            mainPanel.add(weightLabel);
            weightText = new JTextField("100",2);
            weightText.addActionListener(this);
            mainPanel.add(weightText);
            
            
            menuPanel.add(linkPanel);
            menuPanel.add(mainPanel);
            //menuPanel.add(createMenubar());
          menuPanel.setPreferredSize(new Dimension(600,80));
          imagePanel= new RecursiveResult();
          //imagePanel= new JPanel3D();
          imagePanel.setPreferredSize(new Dimension(600,600));
          imagePanel.addMouseListener(this);
           
             imageContainer = new JPanel(new FlowLayout(FlowLayout.CENTER));
             imageContainer.setBackground(Color.WHITE);
             imageContainer.add(imagePanel);
           
        srollPane = new JScrollPane(imagePanel);
        srollPane.setAutoscrolls(true);
        getContentPane().add(BorderLayout.NORTH, menuPanel);
        getContentPane().add(BorderLayout.CENTER, srollPane);
        getContentPane().add(BorderLayout.SOUTH,
        new JLabel("Left Click to Zoom In," +
         " Right Click to Zoom Out", JLabel.CENTER));
      
            addMouseListener(this);
            imagePanel.repaint();             
   
        }
        
        public Container getPanel()
        {
              return this.getContentPane();
        }
        
        
        
       
       public void actionPerformed( ActionEvent event )
       {

             if(event.getSource()==links)
             {
                   string=linkText.getText();
                   
                   if(!(string.equals(previousString)))
                   {
                         showLinks.enable();
                         imagePanel.isThisNew(true);
                         previousString = string;
                         imagePanel.setTotal(0);
                         imagePanel.repaint();
                         imagePanel.setSearch(string);
                         int weightValue = Integer.parseInt(weightText.getText());
                         int depthValue = Integer.parseInt((String)depth.getSelectedItem());
                         imagePanel.setDepth(depthValue);
                         imagePanel.setWeight(weightValue);
                         imagePanel.repaint();
                         
                   }
              
          }
          
          else if(event.getSource().equals(showLinks))
          {
                System.out.println("Show Links");
                imagePanel.showLinks();
          }

        else if(event.getSource().equals(zoomIn))
             {
                   imagePanel.setTotal(0);
                   imagePanel.repaint();
                   string=linkText.getText();
                   imagePanel.setSearch(string);
              size=imagePanel.getSize();
              imagePanel.setPreferredSize(new Dimension((int)(size.getWidth()+100),
(int)(size.getHeight()+100)));
              imagePanel.revalidate();
              imageContainer.doLayout();        
              srollPane.doLayout();
              repaint();
              
          }
                
          else if(event.getSource().equals(zoomOut))
             {
                   imagePanel.setTotal(0);
                   imagePanel.repaint();
                   string=linkText.getText();
                   imagePanel.setSearch(string);
              size=imagePanel.getSize();
              imagePanel.setPreferredSize(new Dimension((int)(size.getWidth()-100),
(int)(size.getHeight()-100)));
              imagePanel.revalidate();
              imageContainer.doLayout();        
              srollPane.doLayout();
              repaint();
              
          }
       
        else if(event.getSource().equals(original))
        {
            imagePanel.setTotal(0);
                   imagePanel.repaint();
                   string=linkText.getText();
                   imagePanel.setSearch(string);
              size=imagePanel.getSize();
              imagePanel.setPreferredSize(new Dimension(600,600));
              imagePanel.revalidate();
              imageContainer.doLayout();        
              srollPane.doLayout();
              repaint();
              
        }
       
       
       } // end method actionPerformed
      
      public void mouseClicked (MouseEvent e)
      {
            if(e.getSource().getClass().equals(imagePanel.getClass()))
            {
            switch(e.getModifiers()) {
                  case InputEvent.BUTTON1_MASK: {
                    imagePanel.setTotal(0);
                         imagePanel.repaint();
                         string=linkText.getText();
                         imagePanel.setSearch(string);
                    size=imagePanel.getSize();
                    int x = e.getX()+1000;
                    int y = e.getY()+1000;
                    imagePanel.setPreferredSize(new Dimension((int)(size.getWidth()+1000),
(int)(size.getHeight()+1000)));
                    //this.setPreferredSize(new Dimension(this.getWidth()+1000, this.getHeight()+1000));
                    //System.out.println("X: "+e.getX() + " Y: "+e.getY());
                    //System.out.println(e.toString());
                    Rectangle r = new Rectangle(e.getX()+800, e.getY()+750, 1, 1);
                    //System.out.println(r.toString());
                    repaint();
                    imagePanel.revalidate();
                    srollPane.doLayout();
                    imagePanel.scrollRectToVisible(r);
                    
                    
                    
                    imageContainer.doLayout();        
                    
                    
                    break;
              }
                  case InputEvent.BUTTON2_MASK: {
                    System.out.println("That's the MIDDLE button");    
                    break;
              }
                  case InputEvent.BUTTON3_MASK: {
                    imagePanel.setTotal(0);
                         imagePanel.repaint();
                         string=linkText.getText();
                         imagePanel.setSearch(string);
                    size=imagePanel.getSize();
                    int x = e.getX()-1000;
                    int y = e.getY()-1000;
                    if((int)(size.getWidth()-1000)<200)
                    break;
                    imagePanel.setPreferredSize(new Dimension((int)(size.getWidth()-1000),
(int)(size.getHeight()-1000)));
                    //this.setPreferredSize(new Dimension(this.getWidth()-1000, this.getHeight()-1000));
                        
                    Rectangle r = new Rectangle(e.getX()-800, e.getY()-750, 1, 1);
                    
                    repaint();
                    imagePanel.revalidate();
                    srollPane.doLayout();
                    imagePanel.scrollRectToVisible(r);
                    
                    break;
              }
            }
            }//end of if statement
      }//end of mouseClicked
       public void mouseEntered (MouseEvent me) {}
       public void mousePressed (MouseEvent me) {}
       public void mouseReleased (MouseEvent me) {}  
       public void mouseExited (MouseEvent me) {}
       
       
}

*****************************************************************
*****************************************************************

AllLinks class create connection to database, statement and calls the DBC class passing
statement to
the methods.


$$$$$$$$$$$$$$$$$$$$$$$$$$$$AllLinks Class$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

package visual2D;
import java.sql.*;
class AllLinks
{
      private static Statement stmt;
      private static int count;
      private static int depth, weight;
      private static int myTotal;
      private static int allLinks[][] = new int[100000][4];
      
      public static int[][] all(String search, int depthVal, int weightVal)
      {
            int id;
            depth = depthVal;
            weight= weightVal;
            count=0;
            createStmt();
            id = DBC.getURLID(stmt, search);
            test(0,id);
            closeStmt();
            return allLinks;
      }
      
      public static String test(int k, int link)
      {
            int links[][];
            int total=0;
            
                  if(k>=depth)
                        return null;
                  else
                  {
                        links = DBC.searchString(stmt,link);
                        total=DBC.getMyTotal();
                        k=k+1;
                        for(int loopCount=0; loopCount<total; loopCount++)
                        {
                              
                              if(DBC.getMyCount(stmt, links[loopCount][1])>=weight)
                              {
                                    allLinks[count][0] = links[loopCount][0];//search string
                                    allLinks[count][1] = links[loopCount][1];//all the links connected to and from search link
                                    allLinks[count][2] = links[loopCount][2];//if the links is tourlid,fromurlid or both then
stores the value '0','1'or '2' respectively
                                    allLinks[count][3] = k;//depth of the link from main search node
                                    
                                    System.out.println(allLinks[count][0]+" : "+allLinks[count][1]+" : "+allLinks[count][2]+"
: "+allLinks[count][3]);
                                    count++;
                                    test(k, links[loopCount][1]);
                              }
                        }
                        
                  }
            return null;
      }
      public static void createStmt()
      {
            try{
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            
            Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:usm","system","peechara");
            
            stmt = con.createStatement();
            }catch(Exception ex){ System.out.println("stmt creating Error");}
      }
      public static void closeStmt()
      {
            try{
                  stmt.close();
            }catch(Exception e){System.out.println("stmt closeing error");}
      }
      
      public static int getCount()
      {
            return count;
      }      
      
      public static String[] getURLNames(int[][] allURLs, int myTotal)
      {
            
            createStmt();
            String[] allNames = DBC.getOurNames(allURLs,myTotal,stmt);
            closeStmt();
            
            return allNames;
            
      }
}




$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Class DBC$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

package visual2D;
import java.sql.*;

class DBC
{
      private static int myTotal;
      
      public static int[][] searchString(Statement stmt,int search)
      {
            int someLinks[][]=null;
            myTotal=0;
            int i=0;
            try{
            //System.out.println("searching: "+ search);
            
            
            ResultSet rset = stmt.executeQuery("select tourlid from urlstruct where fromurlid="+search);
                                                                  
                                                                  
            
            someLinks = new int[10000][3];
            
            while(rset.next())
            {
                  someLinks[i][0] = search;
                  someLinks[i][1] = rset.getInt(1);
                  someLinks[i][2]=0;
                  //System.out.println(i+"="+someLinks[i][1]);
                  i++;
            }
            
            int j=i;
            boolean check=false;
            rset = stmt.executeQuery("select fromurlid from urlstruct where tourlid="+search);
                                                                  
            while(rset.next())
            {
                  int find=0;
                  int id = rset.getInt(1);
                  for(int k=0; k<i; k++)
                        if(id==someLinks[k][1])
                        {
                              check=true;
                              find=k;
                        }
                  if(check)
                  {
                        someLinks[find][2] = 2;
                        //System.out.println("  "+someLinks[find][1]);
                  }
                  else
                  {
                        someLinks[j][0] = search;
                        someLinks[j][1] = id;
                        someLinks[j][2] = 1;
                        j++;
                  }
                        
                  
                  check=false;      
                  
            }
            myTotal=j;            
            int k=0;
                  
            
            }catch(Exception ex){ System.out.println("No Values");}
            
      return someLinks;
      }
      
      
      public static int getURLID(Statement stmt,String search)
      {
            
            int i=0;
            String id=null;
            try
            {
            
                  ResultSet rset = stmt.executeQuery("select urlid from url where url= '"+search+"'");
                  while(rset.next())
                  {
                        i = rset.getInt(1);
                  }
            
                  
            }catch(Exception ex){ i=-1;}
            
            return i;
      }


public static String getURL(Statement stmt,int search)
      {
            
            int i=0;
            String url=null;
            try
            {
            
                  ResultSet rset = stmt.executeQuery("select url from url where urlid= "+search);
                  while(rset.next())
                  {
                        url = rset.getString(1);
                  }
            
                  
            }catch(Exception ex){}
            
            return url;
      }
      
      
public static int getMyCount(Statement stmt,int search)
      {
            
            int myCount=0;
            try
            {
                  
            
                  ResultSet rset = stmt.executeQuery("select Count(*) from urlstruct where fromurlid= "+search+
                                                                                                                               "or tourlid="+search);
                  while(rset.next())
                  {
                        myCount = rset.getInt(1);
                  }
            
                  //System.out.println(search+" My Count="+myCount);
            }catch(Exception ex){}
            
            return myCount;
      }
      
      public static int getMyTotal()
      {
            return myTotal;
      }
      
      public static String[] getOurNames(int allURLs[][], int myTotal, Statement stmt)
      {
            String[] ourNames = new String[myTotal];
            ResultSet rset=null;
            for(int i=0; i<=myTotal; i++)
             {
                  try
                  {
                  
            
                        rset = stmt.executeQuery("select url from url where urlid = "+allURLs[i][0]);
                        while(rset.next())
                        {
                              ourNames[i] = rset.getString(1);
                        }
            
                  //System.out.println(search+" My Count="+myCount);
                  }catch(Exception ex){}
            }
            
            return ourNames;
      }
      
      public static void main(String args[])
      {
            
            int[][] allURLs = new int[5][2];
            allURLs[0][0] = 0;
            allURLs[1][0] = 16;
            allURLs[2][0] = 200;
            allURLs[3][0] = 139;
            allURLs[4][0] = 2210;
            allURLs[0][1] = 0;
            allURLs[1][1] = 1;
            allURLs[2][1] = 1;
            allURLs[3][1] = 1;
            allURLs[4][1] = 1;
            
      }
}

****************************************************************
0
 
JoegalAuthor Commented:
CEHG,

Do I have to sign the J2SDK and Java 3D jars too?
0
Technology Partners: 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!

 
CEHJCommented:
The 3d jars need to be signed, yes
0
 
Mayank SAssociate Director - Product EngineeringCommented:
0
 
CEHJCommented:
:-)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now