Noclassfound error while connecting java with oracle database

hi all
the source code metioned below gets compiled. but when it is run
it gives thefollowing error.
ClassNotFoundException: jdbc.driver.OracleDriver
Exception in thread "main" java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at pract.main(pract.java:16)
import java.sql.*;
class pract
public static void main (String args []) throws SQLException
     try
          Class.forName("jdbc.driver.OracleDriver");
          catch(java.lang.ClassNotFoundException e)
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
          Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@anant:1521:student", "scott", "tiger");
// @machineName:port:SID, userid, pas
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from emp");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
i have included the following driver classes in the classpath
ojdbc.jar,
ojdbc_g.jar,
classes111.jar
but still im unable to connect.
can anyone help me in solving this simple problem.

hi ,
you hav not stated which oracle ur using...still if u r using oracle 9i then u hav to include classes12.jar file in ur lib build classpath and then tryout following changes in code....
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@<host>:<port>:<sid>","scott","tiger");
hope this ll help....

Similar Messages

  • 500 Internal Server Error while connecting JSP with Oracle

    Hello Friends,
    We Have installed Oracle Applications 11i in our orgaization which run on HP-UX 11.11 (HP Unix). I have created a JSP file in which I am trying to connect the database using OracleConnectionCacheImpl Class File in oracle.jdbc.pool directory. But it shows an error message as:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log.
    I have also installed Oracle HTTP Server on my personal machine at which this code runs perfectly only the error comes when i try to connect oracle from Oracle HTTP Server installed on our HP Unix Server.
    the path for pool package is:
    /appltest/apps/prodora/iAS/oem_webstage/oracle/jdbc/pool
    the location of JSP file is:
    /appltest/apps/prodcomn/portal/TEST_test/test
    What I think is I have to play with the CLASSPATh entries, but dont know how. Please help me in solving this issue...
    For your reference the JSP code is:
    <%@ page import="java.sql.*, javax.sql.*, oracle.jdbc.pool.*" %>
    <jsp:useBean id="ods" class="oracle.jdbc.pool.OracleConnectionCacheImpl" scope="session" />
    <%
    try
    ods.setURL("jdbc:oracle:thin:@test:1546:test");
    ods.setUser("kpm_hr");
    ods.setPassword("kpm_hr");
    Connection conn = ods.getConnection();
    Statement stmt = conn.createStatement();
    Resultset rset = stmt.executeQuery("select first_name,last_name from kpm_hr.kpm_hr_emp_mst where empcode='P0580'");
    rset.next();
    out.println(rset.getString(1)+" "+rset.getString(2);
    catch(SQLException e)
    out.println(e);
    } Thanks in adavnce,
    Ankur

    Just to verify, which relevant log files have you found?
    catch(SQLException e) {
    out.println(e);
    } Have you search the console log file?
    A quick observation reveals that your jsp is just a standalone java program executed inside jsp. Suppose you just run it as a standalone program. Any error then?
    Another way going forward is to install oc4j standalone of the same version. It is very easy to install: just download the oc4j-extended.zip and unzip it and run "java -jar oc4j.jar". Put you jsp inside j2ee/home/default-web-app and run. You should see relevant log messages in j2ee/home/log/server.log and j2ee/home/application-deployments/yourApp/application.log.
    You should have Jdeveloper of some appropriate version installed. If you have not, install one. It might be not a little bit high learning curve at first, but the rewards are quick and amazing, especially since jdev 10.1.3. (I am speaking from my experience.) Try it with Jdeveloper.

  • How to connect java with oracle

    can any body show me the code of how to connect java with oracle database.
    thank you

    To configure Oracle JDBC:
    1. Add Oracle JDBC JAR file classes12.zip or ojdbc14.zip to classpath.
    2. Load and register the JDBC driver.
    Class.forName("oracle.jdbc.driver.OracleDriver");
    3. Obtain a connection:
    String url="jdbc:oracle:thin:@<host>:1521:<database>
    Connection con = DriverManager.getConnection(url,
    "myLogin", "myPassword");
    4. Create a SQL statement.
    Statement stmt = con.createStatement();
    5. Obtain a result set.
    ResultSet rs = stmt.executeQuery(
    "SELECT ...");

  • Error in connecting webdynpro with oracle

    Hi
          while connecting webdynpro with oracle, i am getting this type of error. I imported the classes12.jar file also.
    <b>Error:</b>
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    The <b>coding</b> which i used to connect is as follows,
    Class.forName("oracle.jdbc.driver.OracleDriver");
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection(
              "jdbc:oracle:thin:@entegdt36:1521:dbserver",
              "scott","tiger");
              pst=conn.prepareStatement("select * from Test");
              rs=pst.executeQuery();
              while(rs.next())
                   res=res+rs.getString(1);
                   wdThis.wdGetContext().currentContextElement().setName(res);
    Please help me to solve this problem.
    It's very urgent.
    Thanks in advance.

    Hi,
    Go to technical landscapes and create a technical landscape for your ECC backend system.
    This should solve the problem.
    Regards
    Bharathwaj.

  • How to connect Java to oracle Database Express Edition?

    Anyone can help me?
    How to connect JAVA TO ORACLE DATABASE EXPRESS EDITION?

    I suggest you to read this article:
    http://wiki.oracle.com/page/JDBC
    Regards,
    Ricky

  • Error when connecting to an Oracle Database

    Hi, I'm trying to connect to an oracle database by calling a javabean from a jsp page. When I try to connect however I get this error:
    java.lang.UnsatisfiedLinkError: C:\oracle\ora92\jdbc\lib\ocijdbc10.dll: The specified procedure could not be found
         java.lang.ClassLoader$NativeLibrary.load(Native Method)
         java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
         java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
         java.lang.Runtime.loadLibrary0(Runtime.java:822)
         java.lang.System.loadLibrary(System.java:992)
         oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java:2963)
         oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:225)
         oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:348)
         oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:139)
         oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:79)
         oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:563)
         java.sql.DriverManager.getConnection(DriverManager.java:525)
         java.sql.DriverManager.getConnection(DriverManager.java:171)
    I am trying to connect to the database using OCI and its tns name. Also right now I'm just using the tomcat bundled in the netbeans ide.
    Anyone have any ideas on what's wrong?

    Why not use a type IV JDBC driver, available forfree download from Oracle? No
    need for any DLL then.The standard Oracle driver comes with "oci" and
    "thin" drivers.
    Thin driver is 100% java.
    oci driver uses the dlls.
    What version of Oracle are you using? I am guessing
    10?
    Have you got Oracle Client installed on this machine?
    (Stupid question I know)
    What URL connection string are you using?
    Does the "thin" driver work? ie url
    "jdbc:oracle:thin:@[IP_ADDRESS]:[PORT]:[SID]"
    Cheers,
    evnafetsThere's another advantage of the thin driver: you don't have to have the client installed or TNS names defined for it to work.
    %

  • Unable to connect JAVA with Oracle

    I have jdk1.6 and oracle installed on my machine but unable to connect java with database
    have classes12.jar and ojdbc14.jar
    my environmental variables in respect to this are :
    JAVA_HOME= C:\Java\jdk1.6.0_04
    JRE_HOME=C:\Java\jdk1.6.0_04
    PATH=J:\oracle\ora92\lib;
    J:\oracle\ora92\bin;
    C:\Program Files\Oracle\jre\1.3.1\bin;
    C:\Program Files\Oracle\jre\1.1.8\bin
    CLASSPATH=J:\oracle\ora92\jdk\jre\bin\JdbcOdbc.dll;
    J:\oracle\ora92\jdbc\lib\classes12.jar;
    J:\oracle\ora92\jdbc\lib\ojdbc14.jar
    The code is
    import java.sql.*; public class dat1 {               public static void main(String[] args)throws SQLException,ClassNotFoundException {         try     {     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");     Class.forName("com.oracle.jdbc.OracleDriver");     } catch (ClassNotFoundException e) { System.out.println("unable to load driver"); return; }     } }
    the error message is
    Error in thread "main" java.lang.NoClassDefFoundError
    Please Help Me
    Thanks For Reading
    Thanks a lot in Advance For your ANSWERS

    maybe if you asked nicely instead of ordering people around we might tell you.
    As it is all you're going to hear is that you don't need both those jars, as they contain different versions of the same driver.
    I'm not going to tell you which you need, as you should have the documentation to tell you that. But then you also should have the documentation to tell you how to set your classpath properly and you failed to read that too.

  • Connect Problems with Oracle Database Express Edition 11g Release 2

    Hello,
    I am a student trying to install Oracle Database Express Edition 11g Release 2 and SQL Developer on my home system, Win7 64Bit, in order to practice some things I've learned from me DBA class and Developer classes.
    Anyway, I have everything installed, but I am having difficulty connecting as SYS or SYSDBA in the 'Run SQL Command Line', I keep getting the ORA-01017: invalid username/password: logon denied.
    However, If i select the 'Start Database' I get this:
    C:\oraclexe\app\oracle\product\11.2.0\server\bin>
    and I can type sqlplus / as sysdba and it starts up just fine and show user lists me as "SYS".
    but if I go back to 'Run SQL Command Line' I still cannot connect as SYS or SYSDBA...I find this both confusing and frustrating. I don't know if I am in different instances or something like that, but I seem to be limited to connecting only as "SYSTEM". I need SYS because I want to practice creating datafiles, instances and things like that, but I seem to be lost.
    Also, I am trying to create a new DB connection with SQL Developer and I can only us SYSTEM for my login which, if I understand correctly, will limit my privileges. Again When I try to sign in with SYS or SYSDBA I get error'd out. When I installed Ora11gDBExpress I was prompted in input a single password that was supposed to grant me access as SYS or SYSTEM, but I am limited to only SYSTEM for some reason.
    So, I am looking for help/guidance as to what to do.
    Thanks in advance for any and all help,
    Warren

    General rule of thumb, don't use sysdba unless you want to shut down the database, or grant a database user privileges on a sys object.
    A SYSTEM connection is not "limiting", it has the DBA role which means a user with a system connection can do most anything needed, including select/update/delete/drop any user's objects as well as change parameters in the instance.
    The system user can indeed add datafiles, tablespaces, etc. The instance and database should already be created as long as the installer completed all its chores correctly. For XE, per the license agreement only one instance can run on one host. If you want to try creating a database, it will require shutting down the XE instance and creating a new database service, creating the database, and installing the system catalog and any other optional components desired. Good practice indeed, but a bit advanced for the new user.
    Do create users for schemas ... connect system; create user <username> identified by <password> and connect <username> for the schemas (a collection of objects) within the database. Grant the resource and create session privilege to <username> to allow the database user the ability to create tables, indexes, stored procedures, etc.
    There is no "or" in a sys as sysdba connection, from 10g onwards a sys connection requires using the sysdba privilege. To enable a sysdba connection, add your host user to the ORA_DBA group on the host. To verify the OS users in the ORA_DBA group, this might work for win7, in a cmd box ...
    $ net localgroup ora_dba
    ...If your OS user is in the ora_dba group the sys as sysdba password is not relevant, you can in fact type anything for a password. If you wish to connect with the sysdba privilege from a remote client, that is a bit different and requires knowing the password set in the instance password file. Which should be set the same as the system password defined in the installer, but you can change that by creating a new password file. Another slightly advanced topic.
    In Windows IMHO its better to leave the listener and database set to Manual start (in the services applet, Start/Run/services.msc) and start the listener, then the database, when its needed. At least for an XE instance, as its intended for practice and learning RDBMS management.
    Edited by: clcarter on Mar 2, 2012 6:19 PM
    fix typos

  • Getting error while importing schema with ORACLE TEXT

    IMP-00003: ORACLE error 20000 encountered
    ORA-20000: Oracle Text error:
    DRG-52204: error while registering index
    DRG-10507: duplicate index name: WORKORDER_Q, owner: SYS
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.DRIIMP", line 115
    ORA-06512: at line 2
    IMP-00088: Problem importing metadata for index WORKORDER_Q. Index creation will be skipped
    Database version - Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    Os version - Linux nlxs1012.slb.atosorigin-asp.com 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
    We have take export of schema from production db now importing data to qa environment..
    In import facing above error..

    I am importing objects from P20_MAXIMO to Q25_MAXIMO to another database..
    Below is import par file..
    USERID='/ as sysdba'
    FILE=exp_P20_MAXIMO_C2364781.dmp
    LOG=imp_P20_MAXIMO__Q25_MAXIMO_C2364781_1.log
    FROMUSER=P20_MAXIMO
    TOUSER=Q25_MAXIMO
    buffer=1000000
    feedback=100000
    Export parfile
    userid='/ as sysdba'
    owner=P20_MAXIMO
    FILE=exp_P20_MAXIMO_C2364781.dmp
    LOG=exp_P20_MAXIMO_C2364781.log
    buffer=10000000
    feedback=100000
    statistics=none

  • Cant connect java with oracle

    i am new to oracle.
    i cant connect java(jdk1.3) to oracle using 'oracle.jdbc.driver.OracleDriver' in Class.forName() and DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger")
    it shows "class not found" error.
    is there any one to suggest or help me?

    Hi,
    you are posting in wrong forum, as this one is for SQLDeveloper-related issues only. You should post java-related issues in this forum:
    SQL Developer
    However, about your exception you have missed to put the oracle jdbc driver in the classpath.
    Download it from here:
    SQL Developer
    and see more info here:
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/index.html

  • Error while importing tables from oracle database

    Hi
    I am getting the following error when i am trying to import table from oracle database.
    my operating system is windows and my database is oracle.
    [nQSError: 16001]ODBC error state: IM004 code:0 message:
    [Microsoft][ODBC Driver Manager] Driver`s SQLAllocHandle on SQL_HANDLE_ENV failed.
    please help me in resolving this issue.
    Thanks and Regards,
    Raj

    Hi Madan,
    I have done migration Discoverer Admin EUL Layer into OBIEE repository using below methodology.
    Navigate to the <installdrive>\OracleBI\server\Bin directory. There are two important files in this directory: the migration assistant executable file named MigrateEUL.exe and a properties configuration file named MigrationConfig.properties.
    Could you please help me how to migrate discoverer plus workbooks and worksheets into OBIEE Answers?
    go through below link, It will show navigation steps for migrating of EUL from Discoverer to OBIEE.But i need migration of workbooks and worksheets from Discoverer into OBIEE Answers.
    http://www.oracle.com/technology/obe/obe_bi/discoverer/discoverer_1012/discomigration/migrate_disco_biee.htm
    This is very great full help to me …
    Advance thanks for your suggestions.
    Regards
    Duraga Prasad.

  • Error connecting applet with oracle database

    hi all,
    here i m running the following code .
    it executes the following query "Select * from emp";
    the number in the text filed decides the column number to be displayed.
    import java.awt.*;
    import java.applet.*;
    import java.sql.*;
    /*<applet code=project.class width=300 height=200>
    </applet>*/
    public class project extends Applet
    Statement stmt=null;
    Connection conn = null;
    TextField t1;
    public void init()
    t1 = new TextField(2);
    add(t1);
    t1.setText("0");
    public void paint(Graphics g)
    int x=0,y=0,z=0;
    String s1,s2,s;
    try{
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    catch(Exception e)
    try{
    conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@anant:1521:student", "scott", "tiger");
    stmt = conn.createStatement();
    catch(Exception e)
    s1 = t1.getText();
    x = Integer.parseInt(s1);
    try{
    ResultSet rset = stmt.executeQuery("select * from emp");
    while (rset.next())
    s2 = (rset.getString(x));
    g.drawString(s2,100,100);
    stmt.close();
    catch(Exception e){}
    public boolean action(Event event,Object obj)
    repaint();
    return true;
    i m getting following error.
    Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
    at project.paint(project.java:23)
    at java.awt.Container.update(Container.java:1730)
    at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
    at sun.awt.RepaintArea.paint(RepaintArea.java:216)
    at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
    at java.awt.Component.dispatchEventImpl(Component.java:4031)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    this error comes when i run every jdbc applet.
    can anyone suggest any solution.

    Mintu,
    You said:
    i do have to access to jdbc driversNo, you don't. Otherwise you wouldn't be getting that error message.
    Good Luck,
    Avi.

  • Reg: Error while connecting to a remote database as SYS user.

    Hello all,
    When i try to connect to a database as SYS user i'm getting the error as
    ora-01017 invalid username/password logon denied
    But it is logging from the local system where the oracle is installed.
    I created the password file and checked the contents in v$pwfile_users.
    The result is " no rows selected".
    so when i try to grant sysdba to sys user
    grant sysdba to sys;
    i'm getting error as,
    ORA-01994: GRANT failed: password file missing or disabled
    Please help me in resolving this.
    Regards,
    Konda

    I created the passwordfile using the command below,
    orapwd.exe file=E:\app\Administrator\product\11.2.0\dbhome_1\database\PWDfile.ora force=y entries=30 password=<sys_password>
    is this okay...??

  • Error while connecting HCM with IDM

    HI SDN,
    I am now working on connecting HCM (source system) with IDM by referring the document u201C [IDM for SAP System Landscape u2013 Configuration Guide|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/706065c4-3564-2a10-2382-a52fcbd7eefb]u201D .
    In that I am following the HCM Use case implementation. I configured all the steps up to Exporting the HR data to Staging Area (Identity Store) via VDS by using a SQL query. If I say all the steps I followed it will take more time. so I request you to go through the mentioned document. While executing the report (RPLDAP_EXTRACT)  getting some Runtime error. Here is the short dump of that error.
    Short text
        "Function SPLDAP_RECEIVE_ATTRIBUTES is not available"
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPLLDA_EXTRACTION" had to be terminated because it
         has
        come across a statement that unfortunately cannot be executed.
        The error occurred during an RFC call to another system.
        In the target system, a short dump has been written as well.
        More detailed information on the error cause can be found there.
    Error analysis
        An error occurred when executing a REMOTE FUNCTION CALL.
        It was logged under the name "RFC_EXTERNAL_ABORT"
    I have that particular function module in my system and my RFC test connection is also success. so i am very much confused why i am getting that error?
    can anbody help me in fixing this error?
    /* points assured*/
    Regards,
    Tamil K

    Troy, did you ever figure out why you were getting the cannot modify object class error?
    I was able to get around it by fiddling with the IDS config, but comparing that modified config against a new one (that gets the cannot modify object class error) I can't see any relevant difference...
    I'd appreciate some guidance if you have overcome this.
    Thanks. Des.

  • Error While Integrating Unifier with Oracle Business Intelligence Publisher

    Dears,
    I followed up exactly the unifier installation documents, as well as the Configuring the BI Publisher for Unifier.
    And Once I am trying to enter the BI Publisher data in the Unifier Configuration i get an error message "TEST FAILED Connection couldn't be established"
    I am also confused which port to use, i tried both and both gave error:
    BIP Endpoint URL: http://localhost.com:9704    and I tried " http://localhost.com:7001"
    Your support is highly appreciated;
    Karim

    Hi Karim,
    First question is do you have BI Publisher installed and running?
    If so then test if you can get to a login screen with one of the following URLs:
    http://localhost:7001
    http://localhost:9704
    Let us know how you go.
    Regards
    Alex

Maybe you are looking for

  • Phone Dropping calls and disappointed in Verizon

    Very disappointed in Verizon Wirelessly. Over the past year my phone has continuously dropped calls. It's getting worse and worse. I went from have decent service  3 years ago to only being able to talk in my bedroom and kitchen over the past year. o

  • How to prompt for user input in PL/SQL

    How do I prompt for user input in PL/SQL? I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither? If the user chooses

  • S_PL0_86000030

    Hi All, While generating the above report transaction ,account number ,profit centre is not appearing only text is shown. As per my business requirement ,i would like to assign GL acount number ,Profit centre Number ( Not Rext) Is it possible to retr

  • Export Project

    Exported projects have all pictures under original Name. If I need exported project with " Version Name" - how to set-up export? Thank you !

  • IPhoto Library Not Found after Upgrade to Leopard

    I was running the newest iPhoto under Tiger and I just upgraded to Leopard. I tried to open iPhoto and a message said, "iPhoto library not found." It was there before I upgraded from Tiger. I mostly use Adobe Bridge so I didn't have much in iPhoto bu