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.

Similar Messages

  • 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 ...");

  • Unable to connect forms6i with oracle 10g

    hi:
    i am facing a problem to connect forms6i with oracle 10.2 g. i already make a entry in TNSNAMES.ora file in forms folder.
    while i am trying to connect it dispaly "ORA-12203: TNS:unable to conect to destination" error.
    please help. Thanks in advance.
    Regards,
    Abhishek

    Hi
    i already make a entry in TNSNAMES.ora Another option...
    1. Pls Verify that the net service name you entered was correct including no spaces.
    2.Verify that the ADDRESS portion of the connect descriptor which corresponds to the net service name is correct.
    3.Ensure that the destination process (for example the listener) is running at the remote node and the cabel of ur local net work connecting to ur server is well connected and working well.
    4. Test ur local network cabel and try to make the connection to another computer set.
    5.u can check from Start > control panel > administrative tools > services that the service name is started or not if it is Started Restarted or refresh it.
    6. Ensure that the listener is running at the remote node and that the ADDRESS parameters specified in TNSNAMES.ORA are correct.
    and the more ....
    Hope this helps...
    Regards,
    Abdetu...

  • 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....

  • 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

  • Unable to connect Toad for Oracle 9.6 to oracle 10g in a windows 7 64-bit

    Hey friends I am Unable to connect toad with oracle 10 in a windows 7 64 bit environment
    Please Help
    Any advice will be appreciated

    read this one :
    Toad ORA-12154: TNS:could not resolve the connect identifier specified

  • Unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver

    I am unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver vers.2.573.4202.00 on a Win98 computer.
    First, I create a "Net Service Name" in order for the ODBC Driver to find the Oracle server. I then created a System DSN in the ODBC Data Source Administrator and assigned the "Net Server Name" as the server in the "Microsoft ODBC for Oracle Setup". But when I test this DSN with Oracle's provided "Oracle ODBC 32Bit Test vers.2.5.3.1.0" I get an error:
    SQLSTATE: NA000
    Native Error Code:0
    Driver Message:[Microsoft][ODBC driver for Oracle][Oracle]
    This error occurred on all three Win98 computers I have tried. It does however, seem to work fine on WinNT 4.0, and believe it or not, on the two Win95 computers I have tried.
    Does anyone have any fixes, recomendations, or advice?
    Thank you,
    Eric Edwards
    null

    Why are yu not using the Oracle ODBC driver - these can be downloaded from OTN.
    Have you set up a tnsnames.ora entry for the Oracle database you want to connect to? Does this name have a domain name added to it? Check %ORACLE_HOME%\network\admin\tnsnames.ora for the service name. If it is a name of the form :
    name.domain.subdomain
    then you should try using this full name when configuring the ODBC data source.
    null

  • Problem in connecting JSP with Oracle 9i.

    Hi,
    I am having problem in connecting JSP with Oracle 9i.
    I am using windows XP and my JDK version is 1.4. For executing JSP I am using
    "jakarta-tomcat-5.5.4-preconfigured". My database name is global.
    I have set java_home, j2ee_home, oracle_home, path, classpath as follows:
    j2ee_home=c:\sun\appserver
    java_home=c:\sun\appserver\jdk
    oracle_home=C:\oracle\ora92
    path=C:\Sun\AppServer\bin;C:\Sun\AppServer\jdk\bin;C:\oracle\ora92\bin
    classpath=C:\Sun\AppServer\lib\j2ee.jar;C:\oracle\ora92\jdbc\lib\ojdbc14.jar;C:\oracle\ora92\jdbc\lib\nls_charse
    t12.zip
    My code is as follows:
    <%@ page language="java" %>
    <%@ page import ="java.sql.*"%>
    <%
    try
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    Connection conn = DriverManager.getConnection ("jdbc:oracle:oci8:@global", "scott", "tiger");
    catch(SQLException e)
    out.println(""+e);
    out.println("Connected");
    %>
    I tried other program:
    <%@ page language="java" %>
    <%@ page import ="java.sql.*"%>
    <%
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:global","scott","tiger");
    out.println("Connected");
    %>
    I am getting following error:
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 5 in the jsp file: /jsp/oracle.jsp
    Generated servlet error:
    oracle.jdbc.OracleDriver cannot be resolved or is not a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Thanking you in advance,
    Anurag

    maneesh108 wrote:
    hi this is maneesh1) Read the thread it has been answered.
    2) The thread is very old. Don't resurrect old threads.
    I'm locking this zombie thread.
    Kaj

  • Unable to connect SQLState=08004 Oracle ODBC Ora-12154

    Hi Sir/Madam,
    I am Wayne, I need your help to resolve my issue in oracle database 11g.
    1. I installed Oracle 11g Personal Edition, Release 11.2.0.10, 64bits,
    2. Test connection(oracle in oradb11g_home1) is successed in data source, odbc,
    2. Then, I tried to connect this with Visual Basic(Visual Studio 2010), data connections, add connections, .net framework data provider for oracle,
    3. but I received an error message as "Attempt to load Oracle client libraries threw BadImageFormatException."
    4. Then, I download the ODAC(11.2.0.3.0) for 64bits, and installed,
    5. I tried to test the connection, but failed with error message as stated above,
    "Unable to connect SQLState=08004 Oracle ODBC Ora-12154: TNS:could not resolve the connect identifier specified"
    Could you please give me a help on this, do I need to install ODAC for 11g Personal Edition ? Please advice accordingly, thanks.

    Hi;
    Please review:
    https://kr.forums.oracle.com/forums/thread.jspa?threadID=2309520
    http://stackoverflow.com/questions/206055/oracle-ora-12154-tns-could-not-resolve-service-name-error
    Regard
    Helios

  • 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.

  • Connect JAVA with ABAP

    Hi,
    I have a requirement in my project to connect Java with ABAP. I want to access ABAP tables from my java application. I am not sure but I think we can use SAP JDBC drivers to do that.
    I found this link to connect JAVA with ABAP  :
    SAP DB JDBC Driver
    My doubt from this link is where can I get the Host Name for the sandbox system I am using and what is the Database Schema name for the tables created using se11.
    Regards,
    Prateek

    Hi
    If you have direct connection to data base then  you can use
    the JDBC driver for the data base that is in use (We have oracle).
    But usually you have to go through the application server this mean you have to use "SAP Java Connector" that connect to SAP using RFC .
    Talk to your basis people.
    Regards.

  • 'VTK-1000: Unable to connect to the Oracle Management Server

    Hello, I installed ORA 8.1.7 on Win2k, everything went smooth apart from I can't run OEM now, brings the following error:
    'VTK-1000: Unable to connect to the Oracle Management Server. Please verify that you have entered the correct host name and the status of the Oracle Management Server'
    I recall it was ok for NT, there was OracleOra817ManagementServer Service and now there is no any for Win2k..
    If you know any way I can make it up and running please help
    Thanks in advance
    Marina

    services: management server service started successfully.
    but OracleOra90Agent not yet started.
    the current scenario with my oem with login as management server has started with the user:sysman
    password:oem_temp
    still OracleOra90Agent has not started.
    inside oem server management,the discovery wizard is not cofiguring the nodes.
    kindly tell me, that is it due to the Agent, or SOMETHING ELSE.
    please do reply, thanks

  • Can' t connect Java with MySQL

    My goal is to connect Java with MySQL. I found many solutions on Internet, but I always get the same mistake:
    SQLException: No suitable driver
    SQLState: 08001
    VendorError: 0MySQL works fine alone or with php.Only thing left me to think is that the installed versions are not compatible for this mysql-connector-java-5.0.4
    I don't believe that could be a reason.
    Installed versions are:
    Apache Tomcat 5.5.20 Server
    Apache HTTP Server 2.2.4
    PHP 5.2.0
    MySQL 5.2
    jre 1.5.0_11
    jdk1.5.0_11
    Apache Tomacat JK2 connector Version: 1.2.20 File Name: mod_jk-apache-2.2.3.so
    mysql-connector-java-5.0.4
    I also set connector in class path: C:\mysql-connector-java-5.0.4;C:\mysql-connector-java-5.0.4\mysql-connector-java-5.0.4-bin.jar;C:\mysql-connector-java-5.0.4\src\com\mysql\jdbc
    For installation I used manulas from:
    http://apacheguide.org/jsp.php
    http://doc.51windows.net/mysql/?url=/MySQL/ch23s03.html
    Here is also a test code in java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
       public class Connect
           public static void main (String[] args)
               Connection conn = null;
               try {
        conn =
           DriverManager.getConnection("jdbc:mysql://localhost/first_test" +
                                       "user=monty&password=greatsqldb");
        // Do something with the Connection
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
       }i'm desperate, please help or tell me someone who'll know the answer.
    Thank You in advance

    hey buddy .. it seems yr code is wrong .. in getconnection () method u should also specify the port ,which u r not doing ...
    the default port for MySQL is 3306 ... see below i am giving you a sample code ... its working fine .. and dont forget to put the MySQL driver jar path in to classpath and also copy the jar into common/lib folder of your tomcat ....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class MySQLConnectionTest {
         public static void main(String[] args) {
    new MySQLConnectionTest().connTest();
    public void connTest() {
              String tableName = "portfolio"; //change as per setting
              String hostName = "10.81.9.39"; // please change for the target database ip or hostname
              String dbPort = "3306"; //change if not using the default
              String dbName = "tradingsystem"; //change as per the given DB name
              String username = "root"; //change as per setting
              String password = "password"; //change as per setting
              System.out.println("before try");
              Double data=0.0;
         Double data1=0.0;
              try {
    Class.forName("org.gjt.mm.mysql.Driver");
                   System.out.println("before driver manager");
    Connection conn = DriverManager.getConnection("jdbc:mysql://"+hostName+":"+dbPort+"/"+dbName, username, password);
    String query1 = "select * from "+tableName+" where User_id='trader1' and Stock_Type='Equity'";
    System.out.println("quesry1="+query1);
    Statement stmt = conn.createStatement();
    ResultSet rs1 = stmt.executeQuery(query1);
    while(rs1.next())
         System.out.println("hiiiiii for rs1");
         System.out.println(rs1);
         Quantity=(Integer)rs1.getObject(5);
         MarketPrice=(Double) rs1.getObject(8);
         data=Quantity*MarketPrice;
         data1+=data;
         System.out.println("data1="+data1);
         i=0;
    rs1.close();
    stmt.close();
    conn.close();
    } catch (ClassNotFoundException e) {
    e.printStackTrace(System.err);
    } catch (SQLException e) {
    e.printStackTrace(System.err);
    i hope it will work for u...
    cheers,

  • An error occured when connecting java with Ms Access

    Hello Everybody
    I am a new developer in java and want to connect java with Microsoft Access
    i am using JCreator LE
    My code is to insert 3 records for 3 members and then save them in DB and retrieve the information
    Here is the code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "Information";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( connURL ,"","");
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception e) {
                System.out.println("An error Occurred in Connecting with the DB " );
    }and the error is
    Beginning Connection
    Connection done successfully
    An error Occurred in Connecting with the DB
    it didn't insert information in the DB

    Well, thank u i have traced the error and fx it
    but
    how to modify the code and keep the user entering 3 values and search for the entered values??
    Here is the correct code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "jdbc:odbc:Project";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( accessFileName);
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception err) {err.printStackTrace();}
    }

  • 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

Maybe you are looking for

  • Can we view data in Multiprovider

    Hello All In one of my interview he asked me can v view data in multiprovider.(Not in reporting level). I said no,he said yes? If anyone knows abt this pl let me know. Regards balaji

  • SAP Business One has encountered a problem and needs to close. When opening a CR report imported in B1.

    Hi All, I am using SAP B1 version 9.0 PL 06. I imported a crystal report, defined FMS for choosing the selection criteria in the parameters. But when I run the report, it gives the dump error and comes out. this happens in the standard crystal report

  • Doesn't recognize FCP7 the thundebolt

    hi, i have a big issue with FCP 7... in my new iMac its doesnt recognize the thunderbolt adapter to Firewire 800 in Log and Capture... i have a dvd player that its RCA output, then i have a RCA to DV (Firewire400), then i have a FW400 to FW800 adapte

  • File sharing not working for any new accounts

    I am using the latest version of Mavericks. For every new account I set up (Sharing, Administrative, Standard) trying to set up file sharing on a directory fails. When I set up the account, select a directory (on the boot drive or on an external driv

  • MM ECC 6.0 document

    I want to know the recent new features in MM modules for ECC 6.0 Appreciate any links or inputs