Results 1 to 6 of 6
  1. #1
    OMFGITSROHIT is offline Member
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Default Database problem.

    Errors-

    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.Class.forName0(Native Method)


    packages-

    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;

    <code>
    :confused::confused:
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
    String user= new String(jTextField1.getText());
    String pass= new String(jPasswordField1.getPassword());
    if(a<4)
    {
    Connection con = null;
    String driver = "oracle.jdbc.driver.OracleDriver";
    //String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    String user1 = "scott";
    String pass1 = "tiger";
    try{
    Class.forName(driver);
    con = DriverManager.getConnection("jdbc:oracle:oci8:@loc alhost",user1,pass1);
    //con = DriverManager.getConnection("jdbc:odbc:test",user1 ,pass1);
    //con = DriverManager.getConnection("jdbc:odbc:loginsource ","scott","tiger");
    Statement s=con.createStatement();
    ResultSet password=s.executeQuery("Select pass from login where username="+user);
    //s.close()
    if(pass.contentEquals(password.getString(1)))
    {
    a=0;
    JOptionPane.showMessageDialog(rootPane, "Access Granted");
    ResultSet access=s.executeQuery("Select access_power from login where username="+user);
    access_power=access.getString(1);
    new Exam_Season().setVisible(true);
    this.setVisible(false);
    }
    else
    {
    JOptionPane.showMessageDialog(rootPane, "Access Denied.");
    a++;
    }
    }
    catch(Exception e)
    {
    e.printStackTrace();
    JOptionPane.showMessageDialog(rootPane, "Connection not successful.");
    }
    }
    else
    {
    JOptionPane.showMessageDialog(rootPane, "Too many attempts.");
    System.exit(0);
    }

    }
    </code>

  2. #2
    jambon is offline Member
    Join Date
    Nov 2009
    Posts
    9
    Rep Power
    0

    Default Re: Database problem

    Do you have the ojdbc6.jar (or equivalent version) in your classpath?
    -J

  3. #3
    OMFGITSROHIT is offline Member
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Default

    Yeah ojdbc14.jar

  4. #4
    jambon is offline Member
    Join Date
    Nov 2009
    Posts
    9
    Rep Power
    0

    Default

    Hmmm..
    I'm using Oracle JDeveloper 11g and I was getting that error until I put the jar file in the Project folder and then using Project Properties added the reference to the jar file in the Libraries and Classpath area.
    But I don't suppose that's any help.
    -J

  5. #5
    OMFGITSROHIT is offline Member
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Default

    I'll check that out and get back to you. Thanks.

  6. #6
    OMFGITSROHIT is offline Member
    Join Date
    Mar 2010
    Posts
    23
    Rep Power
    0

    Default Almost.

    Thanks a bunch dude. I think something's resolved.

    I'm no more getting the classpath error or the message box which says "Connection not successful" (placed in the exception part). New errors that I've got are-

    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: oracle.jdbc.oci8.OCIDBAccess.make_c_state(ZZ) I

    at oracle.jdbc.oci8.OCIDBAccess.make_c_state(Native Method)
    at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.jav a:397)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleC onnection.java:346)
    at oracle.jdbc.driver.getconnectionInstance(OracleDri ver.java:468)
    at oracle.jdbc.driver.connect(OracleDriver.java:314)

Similar Threads

  1. netbeans database problem
    By bikkerss in forum JDBC
    Replies: 10
    Last Post: 01-04-2010, 09:03 AM
  2. problem with connecting database
    By ravidasineni in forum AWT / Swing
    Replies: 1
    Last Post: 11-24-2009, 06:04 AM
  3. Problem with database connection
    By mainy in forum New To Java
    Replies: 3
    Last Post: 08-07-2009, 11:43 PM
  4. Problem in connecting to database..
    By Preethi in forum New To Java
    Replies: 10
    Last Post: 06-26-2008, 05:53 AM
  5. Annoying database problem!
    By DC1 in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 09:43 AM

Posting Permissions

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