Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Oracle connection

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Oracle connection

    Hello everybody,

    I'm developing my first Java Applet and I'm already behind a wall. I spent a lot of time trying to understad it and solve it but nothing!!!

    When I try to connect to the db I receive the following error:

    access denied ("java.util.PropertyPermission" "oracle.net.tns_admin" "read")

    in the source code row

    con = DriverManager.getConnection(connect_string);


    A similar not applet project works fine...



    This is my HTML:
    ================================================== ====================
    <html>
    <head>
    <title>TEST</title>
    </head>
    <body>

    <h1>TEST</h1>

    This is a test<p>

    <hr>
    <applet codebase="file:///D:/Java Tutorials/Test1/build/classes"
    code="test/RunProcApplet.class" width=800 height=275>
    <param name="text" value="Test1">
    <hr>
    Your browser does not support Java applet.
    <hr>
    </applet>

    <hr>
    ================================================== ====================


    an this is my java:

    ================================================== ====================

    // Import the JDBC classes
    import java.awt.*;
    import java.sql.*;
    import oracle.jdbc.*;
    import oracle.sql.*;


    public class RunProcApplet extends java.applet.Applet
    {

    // The connect string

    static final String connect_string = "jdbcracle:thin:USER/PASSWORD@//SERVER:1521/SID";

    // The query we will execute
    static final String query = "select * from TAB1";

    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;




    // The button to push for executing the query
    Button execute_button;

    // The place where to dump the query result
    TextArea output;


    // Create the User Interface
    public void init ()
    {
    this.setLayout (new BorderLayout ());
    Panel p = new Panel ();
    p.setLayout (new FlowLayout (FlowLayout.LEFT));
    execute_button = new Button ("Start");
    p.add (execute_button);
    this.add ("North", p);
    output = new TextArea("", 8, 200, TextArea.SCROLLBARS_BOTH);
    this.add ("Center", output);
    }

    // Do the work
    @Override
    public boolean action (Event ev, Object arg)
    {
    if (ev.target == execute_button)
    {
    try
    {
    output.append("Click Button\n");
    // See if we need to open the connection to the database
    if (con == null)
    {
    // Load the JDBC driver
    output.append ("Registering driver...\n");
    Class.forName("oracle.jdbc.driver.OracleDriver");

    // Connect to the databse
    output.append ("Connecting to " + connect_string + "\n");
    con = DriverManager.getConnection(connect_string);
    output.append ("Connected\n");
    }

    // Create a statement
    stmt = con.createStatement();

    // Execute the query
    output.append ("Executing query " + query + "\n");
    rs = stmt.executeQuery(query);

    // Dump the result
    while(rs.next())
    {
    output.append(rs.getString("COL1") + "\t");
    output.append(rs.getString("COL2"));
    }


    // We're done
    output.append ("done.\n");
    }
    catch (Exception e)
    {
    // Oops
    output.append("Error!!!\n");
    output.append (e.getMessage () + "\n");
    }
    return true;
    }
    else
    {
    return false;
    }
    }
    }

    ================================================== ====================


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,296
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Oracle connection

    Unsigned applets are limited due to security, in other words, sign the applet. See What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Java Applets)

Similar Threads

  1. Shared connection or individual connection?
    By newbie14 in forum Java Networking
    Replies: 6
    Last Post: January 12th, 2013, 03:10 AM
  2. Blob in Oracle
    By Hrithik in forum Java Theory & Questions
    Replies: 0
    Last Post: October 16th, 2012, 04:40 AM
  3. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  4. jsp and oracle
    By sri latha in forum JDBC & Databases
    Replies: 0
    Last Post: March 10th, 2010, 08:29 AM
  5. Oracle and Sun
    By copeg in forum The Cafe
    Replies: 2
    Last Post: January 31st, 2010, 06:00 AM

Tags for this Thread