Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Location
    San Diego
    Posts
    4

    Angry Unanswered: connection == null

    hi,

    I am trying to connect to oracle using jdbc thin drivers from a applet. The applet is stored on the same server as oracle, so there are no problems with remote access. I also use the exact same code for a logon page to get me into this applet and it works just fine. I wrote the logon page in jsp. I am guessing it has something to do with the applet but all the sources I looked up says I have the correct code. It has nothing it do with the classpath because that is set up just fine. and like I said this work with my logon page. Any ideas?

    Code snipet...

    ...
    try
    {
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "68.166.247.38";
    String portNumber = "1521";
    String sid = "mailenf1";
    String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
    connection = DriverManager.getConnection(url, userID, pwd);

    } catch (ClassNotFoundException e) {
    jTextArea1.setText("Class not found");
    } catch (SQLException e) {
    jTextArea1.setText("SQLException: " + e.getMessage());
    while((e = e.getNextException()) != null)
    jTextArea1.setText(e.getMessage());
    }
    ...


    Thanks in advance,
    Casen

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Sorry I can't offer any suggestion because you neglected to actually post the SPECIFIC & EXACT error message(s) you are getting.

    Can you sucessfully log into this database via any other application
    that uses SQL*Net?

  3. #3
    Join Date
    Nov 2003
    Location
    San Diego
    Posts
    4
    Originally posted by anacedent
    Sorry I can't offer any suggestion because you neglected to actually post the SPECIFIC & EXACT error message(s) you are getting.

    Can you sucessfully log into this database via any other application
    that uses SQL*Net?


    Well at first there was no error, that was the problem, but after I changed a bit of logic around I realized I was getting an illegal access error, which means I either have to turn it into a servlet or sign it. Is there any other way around it?

    If there isn't another way, how do you go about adding a link to the cert file in your html? Or would it be better to change it to a servlet?


    thanks,
    Casen

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    The database does not know or care about any "certificate" nonsense.
    The database does not know or care about how the client initiates a connection request (i.e. servlet, jsp, asp, sqlj, etc.)
    If/when the connection request is "well formed" and contains a
    valid username/password, the client will be connected to the DB.
    Until that happens errors will result from a failed connection request.

  5. #5
    Join Date
    Nov 2003
    Location
    San Diego
    Posts
    4
    Well, thank you for pointing that out, I was reading another board and someone mentioned that it might have to be done that way.


    Here is the error I am now getting....

    java.security.AccessControlException: access denied (java.util.PropertyPermission oracle.server.jserver.version read)
    at java.security.AccessControlContext.checkPermission (Unknown Source)
    at java.security.AccessController.PropertyAccess(Unkn own Source)
    at java.lang.SecurityManager.checkPermission
    at java.lang.SecurityManager.checkPropertyAccess
    at java.lang.System.getProperty
    at oracle.jdbc.driver.OracleDriver.getConnectionInsta nce
    at oracle.jdbc.driver.OracleDriver.connect

    here is a bigger snipet of code....

    String userID = getParameter("name");
    String pwd = getParameter("pwd");


    //testing to make sure I pull in parameters correctly
    jTextArea1.setText(userID);


    Connection connection = null;
    try
    {
    // Load the JDBC driver
    String driverName = "oracle.jdbc.driver.OracleDriver";
    Class.forName(driverName);

    // Create a connection to the database
    String serverName = "68.166.247.38";
    String portNumber = "1521";
    String sid = "mailenf1";
    String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
    connection = DriverManager.getConnection(url, userID, pwd);
    } catch (ClassNotFoundException e) {
    jTextArea1.setText("Class not found");
    } catch (SQLException e) {
    jTextArea1.setText("SQLException: " + e.getMessage());
    while((e = e.getNextException()) != null)
    j TextArea1.setText(e.getMessage());
    }


    //testing if connection exists.
    if(connection == null)
    jTextArea1.setText("Null")


    The connection is always equal to null....

    Any ideas?
    Thanks,
    Casen

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Once again
    Can you sucessfully log into this database via any other application
    that uses SQL*Net?

  7. #7
    Join Date
    Nov 2003
    Location
    San Diego
    Posts
    4
    I am afraid that I do not know what exactly SQL *Net mean, but I am able to login using jsp through an html page using the exact same code.

    Does it have anything to do with setting the applets permissions? I am afraid I am not familiar with that either.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •