Using JDBC with Oracle

I have just completed compiling and running a simple UI through a java command line interface, however part of my program is running into a problem. I have to connect to Oracle through JDBC, but the server I am not on does not have the oracle drivers. I have copied them over (in tar as distributed) but I have never had to extern any thing like this. I am running on a standard linux bash prompt and need to know what to do to actually change everything so my program can run the database connectivity.
Simply put, is there a way to compile so the byte code never needs the .jar, and if not how about making my program see the jar which is in my root folder (not root on the server, but my user root folder)
I hope that was enough info, if not I'll do my best to provide more.

Hmm, maybe I'm not quite making sense.
Let's say I want to run my program on my neighbor's machine (A) to connect to an Oracle database on my machine (B). My neighbor has Java version 1.4.2, and my machine has Java version 1.4.2 also. My oracle database is running Oracle 8i (8.1.6.0.0) my machine. Let us also assume that my neighbor, while desiring a program to connect to my database, wants everything to be included in a single directory and no global system settings to be permananty changed. He doesn't mind if I change setting for the current session if need be.
Now, I make the Java program on my machine and it works just fine. Since I have Oracle installed on my machine the command "java dbConnect" has no problem running. Now I take the program over to my neighbor's computer with the following files in the current program directory (not the java installation directory):
dbConnect
ojdbc14.jar
This I hope would allow me to run the program since I thought (in error) that the program would probably be able to find the ojdbc14.jar since it is in the directory of the dbConnect program. Unfortunately it runs correctly, then fails to load the oracle driver.
So now here is my real question. I want to be able to have my neighbor run my application, so what do I do to run the application dbConnect.java on their computer?
I have tried the following, however it gives an exception in the thread when I run this
javac dbConnect.java
java -classpath ./ojdbc14.jar dbConnect
Exception in thread "main" java.lang.NoClassDefFoundError: dbConnect.The program right now is simply a test to see if I can load the driver and make a connection, and it works on my system, so there should be no problems:
import java.io.*;
import java.sql.*;
public class dbConnect
    //Create an input stream for reading data from the user
    private static BufferedReader stdin =
        new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args)
        try{
            //>Load the Oracle JDBC Drivers
            try
                Class.forName("oracle.jdbc.driver.OracleDriver");
            catch(Exception e)
                System.out.println("Failed to load Oracle driver.");
                System.exit(0);
            //>Get username, password, and url for Oracle DB connection.
            String user, pass, url;
            System.out.println("Please enter your username: ");
            user = stdin.readLine();
            System.out.println("Please enter your password: ");
            pass = stdin.readLine();
            url = "jdbc:oracle:thin:@somewhere:1521:csl";
            Connection conn = null;
            Statement stmt = null;
            //>Successfully connect to the Oracle database using JDBC and CSLab account.
            try
                conn = DriverManager.getConnection(url, user, pass);
                System.out.println("Connection made!");
            catch(Exception e)
                System.out.println("Incorrect login information.");
                System.exit(0);
        }catch(Exception e){
            System.out.println("Exception in main program.  Terminating process.");
}

Similar Messages

  • Why folks afraid to use jdbc with oracle

    I use:
    1) select * from russian_name;
    2) native2toascii
    3) javac
    4) java
    Java.langArrayIndexOutOfBoundException
    at oracle.jdbc.dbaccess.DBConversion.ut8BytesToChar
    In the case of non existent table name it throw:
    SqlException - table does not exist - just right
    In win, unix, linux - everything with different versions.
    But sometimes it return many recods looks like - "KG UYGUYBG (null) (null) iloirdoidfogidf oidro oireio ddfoidfoid foi9eri o9er (null) (null)"...

    Hi,
    I'm new to using JDBC. I have found some really good
    sources online that have good info on how to get
    started and all. However, I do have a question.
    I'm trying to access an Oracle store with JDBC.
    However, in my code, certain classes and such cannot
    be resolved; i.e. I am missing an import or two. So,
    what do I need to set on my classpath, if that is
    necessary (I have JRE 1.5.0_06, which includes JDBC,
    right?), and what files do I need to import?Includes all the java.sql interfaces, but not the Oracle implementation. You need to download that from Oracle:
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
    Put that ojdbc14.jar in your project's CLASSPATH. You do not need to import any Oracle-specific classes.
    Let me give a quick example. When I type this:
    Connection connection = null;Connection cannot be resolved. Sounds like you need to re-read the JDBC tutorial.
    So my question is,
    what must I import to my Java class in order to use
    this effectively?You don't need to import, but you do need to load the Oracle JDBC driver class and then get a Connection from the DriverManager, just as all the tutorials show you.
    %

  • Using jdbc with oracle-for-win95

    i am using oracle thin driver to connect my java code with oracleforwin95 i think it is called as personal oracle, while getting conection DriverManager.getConection("drivername@host:port(1521):sid","user","password") there is no sid for oracleforwin95 if i keep it blank i get an error connection refused some thing like that even i cannot use dsn for connection what is the problem should i use another driver if yes which one it is and from where it can be downloaded, or should i need to configure my oracle. please help me.

    This is my code given below
    import java.sql.*;
    public class Oconnection
         Connection conn;
         Statement st;
         PreparedStatement pst,pstissue,pstret,pstbook;
         public Oconnection()
              try
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","manager");
              catch(Exception ex)
                   System.out.println(ex.getMessage());
                   ex.printStackTrace();
         public static void main(String args[])
              new Oconnection();
    *****************************************************8
    Error
    C:\Library>java Oconnection
    Io exception: The Network Adapter could not establish the connection
    java.sql.SQLException: Io exception: The Network Adapter could not establish the
    connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:211)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:324)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:266)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:365)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at Oconnection.<init>(Oconnection.java:17)
    at Oconnection.main(Oconnection.java:39)
    I am using Oracle for win95 or i think it is oarcleforwin98 .
    The sid of my database i found through query given by you was orcl, what changes soulh i do int he code so that it works.

  • Error when trying to use LogMiner with Oracle 8.1.6.0.0

    Hi everybody,
    I'm trying to use LogMiner with Oracle 8.1.6.0.0. When I execute the following code with SQL*Plus, I have an error.
    BEGIN
    DBMS_LOGMNR.START_LOGMNR
    (options =>
    dbms_logmnr.dict_from_online_catalog);
    END;
    The error displayed by SQL*Plus is:
    PLS-00302: 'DICT_FROM_ONLINE_CATALOG' must be declared.
    Please, how to solve this problem?
    Thanks you in advance for your answers.

    user639304 wrote:
    Hi everybody,
    I'm trying to use LogMiner with Oracle 8.1.6.0.0. When I execute the following code with SQL*Plus, I have an error.
    BEGIN
    DBMS_LOGMNR.START_LOGMNR
    (options =>
    dbms_logmnr.dict_from_online_catalog);
    END;
    The error displayed by SQL*Plus is:
    PLS-00302: 'DICT_FROM_ONLINE_CATALOG' must be declared.
    Please, how to solve this problem?
    Thanks you in advance for your answers.Looking at the 8.1.7 doc set (the oldest available on tahiti) I get no hits when searching for 'dict_from_online_catalog'. Searching the 9.2 doc set turns up a reference. Looks like you are trying to use an option that isn't available in your version of Oracle.

  • Using Tuxedo with Oracle Real Application Clusters (RAC)

    Hi all ,
    Our present Producation environment is Tuxedo8.0 with Oracle 9i as database .
    We are planning to implement oracle RAC .
    Can any one tell us , with the current tuxedo version which is 8.0 ,can we for RAC Or we need to upgrade Tuxedo to 9.1 for RAC Implementation?
    If anyone has Implemented Tuxedo and Oracle with RAC successfully
    Pls share your experience.
    Thanks In Adavance
    Nadeer .

    Subbu,
    As I mentioned earlier in this thread, support for Oracle RAC has been
    implemented in Tuxedo 9.1 and in the Tuxedo 8.1 and Tuxedo 9.0 rolling patch
    streams. There are no plans to backport this feature to Tuxedo 8.0. If you
    plan to use RAC transactionally and if it is possible for multiple services
    that could be located on different RAC instances to be accessed in a single
    transaction (which will be true for most applications), then you should
    upgrade to a version of Tuxedo with support for Oracle RAC. The
    documentation at http://e-docs.bea.com/tuxedo/tux91/ads/adorac.htm#248431
    gives an overview of RAC support in Tuxedo.
    Ed
    <Subramonian Arumugom> wrote in message news:[email protected]..
    Hello Nadeer, Hello Ed,
    Has the implementation of Tuxedo8.0 with Oracle RAC was completed
    successfully ?.
    If it is done , I have few doubts. Could you please help me ?.
    1) I hope your Tuxedo middleware connects to the oracle Database using
    Oracle XA resource manager and the TMS server built using buildtms with
    oracle as RM .As per the mail from Ed, migration of Tuxedo9.1 should be done
    before moving to Oracle RAC.
    Also from BEA documentation, Oracle RAC support was given as new feature in
    Tuxedo9.1.
    Our Application uses Oracle RM to connect to Oracle DB[ Oracle 10g] from
    Tuxedo8.0. So do we need to upgrade to Tuxedo9.1. for using Oracle RAC ?.
    Thanks for your help
    Best Regards
    Subbu
    #9880278452
    Edited by subramonian.a at 04/16/2007 12:15 AM
    Edited by subramonian.a at 04/16/2007 12:19 AM
    Edited by subramonian.a at 04/16/2007 1:37 AM
    Edited by subramonian.a at 04/16/2007 8:20 AM

  • Using XA with Oracle ERP application

    Hi,
    We have two Tuxedo Domains that we need to establish global transaction:
    First Domain - Tuxedo 6.4 with Oracle 8.0.6 database.
    Second Domain - Tuxedo 6.4 with Oracle ERP application (Oracel version 8.0.5)
    A Client that calls a Tuxedo server in the first domain this service doing some work
    on the database and then calls another service in the second domain (using Domain
    connection).
    The service in the second Domain activate a Oracle API (package) from the ERP application.
    The Rollback works but we problem with the commit. We recieve the following Oracle
    Error - ORA-06574: Function "VIEW_ALL" references package state can not execute remotly.
    Revital Bloom
    [email protected]

    Subbu,
    As I mentioned earlier in this thread, support for Oracle RAC has been
    implemented in Tuxedo 9.1 and in the Tuxedo 8.1 and Tuxedo 9.0 rolling patch
    streams. There are no plans to backport this feature to Tuxedo 8.0. If you
    plan to use RAC transactionally and if it is possible for multiple services
    that could be located on different RAC instances to be accessed in a single
    transaction (which will be true for most applications), then you should
    upgrade to a version of Tuxedo with support for Oracle RAC. The
    documentation at http://e-docs.bea.com/tuxedo/tux91/ads/adorac.htm#248431
    gives an overview of RAC support in Tuxedo.
    Ed
    <Subramonian Arumugom> wrote in message news:[email protected]..
    Hello Nadeer, Hello Ed,
    Has the implementation of Tuxedo8.0 with Oracle RAC was completed
    successfully ?.
    If it is done , I have few doubts. Could you please help me ?.
    1) I hope your Tuxedo middleware connects to the oracle Database using
    Oracle XA resource manager and the TMS server built using buildtms with
    oracle as RM .As per the mail from Ed, migration of Tuxedo9.1 should be done
    before moving to Oracle RAC.
    Also from BEA documentation, Oracle RAC support was given as new feature in
    Tuxedo9.1.
    Our Application uses Oracle RM to connect to Oracle DB[ Oracle 10g] from
    Tuxedo8.0. So do we need to upgrade to Tuxedo9.1. for using Oracle RAC ?.
    Thanks for your help
    Best Regards
    Subbu
    #9880278452
    Edited by subramonian.a at 04/16/2007 12:15 AM
    Edited by subramonian.a at 04/16/2007 12:19 AM
    Edited by subramonian.a at 04/16/2007 1:37 AM
    Edited by subramonian.a at 04/16/2007 8:20 AM

  • Using OCCI with Oracle XA Library

    Is it possible to use OCCI with Oracle XA Library?
    the XA function xaoSvcCtx() can returns the OCI service handle
    for a given XA connection. but how to convert it to the OCCI
    Connection class?
    any comments would appreciate
    Ray

    Hi Ravi,
    We are now building CORBA application with C++. some programs
    manage transaction through Transaction service(a TM of X/OPEN
    DTP architecture), these programs must use XA Library.
    OCCI is a wonderful tool for C++ programer,with OCCI building
    a persistent layer over ORACLE is very simple.
    But if OCCI not work with XA we have no choice but PRO*C or
    OCI ,which's actually C style tool and hard to use especially
    in object mode.
    So we hope OCCI can provide this feature in next release. and
    I beleive This feature is necessary,It's very common using a
    transaction monitor such as ORACLE Application Server .
    regards,
    Ray

  • Using Mts With Oracle Database

    I m building Com using Visual basic.I have made them transactional using MTS.first i have firstly user Sql Server database.the components are working properly.but when i
    have made back end as Oracle the Trasactions
    fails. if i make them not Mts object then it will function properly. I have read article from microsoft site "Using Mts with Oracle".acc to them a file named XA80.dll should be on ur system on which mts is runing.I have made a database server and a client on which Mts is installed.But XA80.dll
    was not found. whats the problem .tell me solution if anyone can.
    i have installed OEM GUI which installs XA80.dll on ur system.but when i tested microsoft test program which checks weather ur Oracle supports Mts or not fails at the end. When calling XA_Open_Entry it gives error with return code -3
    Plz tell me Solution
    Thankx in advance
    null

    Hi,
    Oracle JVM in 11gR2 (the latest release) supports Java 1.5 only. So no, you won't be able to load classes compiled with target class level 1.6 into DB. But you surely may explicitly set target class level of 1.5 in javac and then load compiled classes. Or you may not use 1.6 features in your code and then CREATE JAVA SOURCE from it.

  • Using psp with oracle text.

    we are design a simple document management application using psp with oracle text.
    we can query on index and finding the record and display the result on browser page.
    but we can't take document link on the same browser page. So we can't take document itself.
    We are using Oracle database release 1 text
    Thanks for your help.

    Sorry. The correct one is http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/text.920/a96517/acase.htm#620714

  • Using jfreechart with oracle forms 11g

    Hi everybody,
    I'm using jfreechart with oracle forms 11g to continue having graphs in my application since i'm migrating from forms 6i. I've already got it working and it's great. Just have one problem left. I don't know how to change the axis labels. In Bar charts, it comes with "Values" in y axis and "Category" in x axis by default. I wanted to change that or make it dissapear. Anyone knows how to?

    I've never used the jFreeChart, but according to their website you can use the "setLabel" method to set the label for an axis. Check out Axis (JFreeChart Class Library) for more information.
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Can we use WebUtil with Oracle Forms 6i

    Can any one tell me if we can use WebUtil with Oracle Forms 6i..I have 11.5.9 instance of oracle apps and i want to use some features of WebUtil to customize one of seeded Oracle Form.
    Any pointers in this regard are quiet welcome.
    Thanks,

    Strictly speaking no...however you could "backport" the webutil code and in theory you could get some of the functionality to work - this is not supported in the context of oracleForms although Oracle Applications may have their own specific solution/certification of this.
    Regards
    Grant Ronald

  • How to use unload query using JDBC with Informix database

    Hi friends,
    How can i use unload query using JDBC with Informix database?
    When i use it as "unload to 'abc.txt' select * from ........" it gives syntax error.I want to take the data of a table to a file.With dbaccess i can use it but i need to do it using jdbc.
    Thanks,
    Raneesh.

    To the best of my ability to tell, the right way to use this product from within Power Query would be to use its API. Unfortunately, we don't currently support either of the methods needed to be able to authenticate with the service (OAuth 2.0 and a relatively-custom
    digest-based method). Adding a mechanism to allow use of arbitrary OAuth-protected resources is a fairly high priority for us, and I hope we'll be able to deliver something before mid-2015.
    Scraping the website is very hard to do well -- both from an authentication and from a data discovery perspective.

  • Problem while using XML with Oracle

    I have a problem using XML with oracle applications
    The process I am following
    1. Making a XML string.
    2. Parsing it to get a document
    3. Free the parser using xmlparser.freeparser
    4. Traversing through nodes .
    5. Freeing the document.
    The whole Process is executed in batch mode.
    The problem occurs after executing the procedure for 5000 records and I get the error
    ORA-04031: unable to allocate 4176 bytes of shared memory ("shared pool","unknown object","sga
    heap","library cache")
    Can you please help me out to overcome this problem
    It's urgent
    I have
    Oracle version 8.1.7.0.0
    XML version 1.2
    OS Windows NT
    To resolve the problem I have increase shared memory size and java initialization parameters ,which seems OK
    Looking forward for your answer.

    Hello, Reena
    Your process flow seems to be correct in term of getting/freeing memory.
    Following error
    The problem occurs after executing the procedure for 5000 records and I get the error
    ORA-04031: unable to allocate 4176 bytes of shared memory ("shared pool","unknown object","sga
    heap","library cache")may be caused by memory leaks in xdk or memory fragmentation(due to get/free memory cycle)
    To find out if this is an memory leak issue you could try to monitor V$SGASTAT from one session while running your batch process in another session.
    To prevent (or lower its impact) fragmentation issues try to PIN objects, and adjust java_pool_size and shared_pool_reserved_size.
    Anyway, counsult your Oracle DBA.
    Oracle version 8.1.7.0.0I think, you should apply database patch first of all. The latest one (8.1.7.4.x) could be accured from Metalink.

  • How use jdbc with swing ? i am new in this concept.

    hi
    freinds,
    i am new in java can any one give the example which explain the how to use jdbc with swing.
    thanks in advace.
    satish
    thanks.

    See here  >  http://support.apple.com/kb/HT4236
    More info in the User Guides for your Devices...

  • Using Java with Oracle Spatial

    I am using the JDBC (Java classes dowloaded from
    technet.oracle.com - (sdoapi.zip)) together with Oracle Spatial
    8.1.6. I am writing a collection of Linestrings into Oracle
    Spatial using the supplied java classes(sdoapi.zip). I use the
    function createGeometryCollection(myCollection)to write the
    Linestring collection to Oracle Spatial and they are written to
    the database without error. However, when I try to read the
    object back I get the following error:
    Exception in thread "main"
    oracle.sdoapi.geom.InvalidGeometryException
    at oracle.sdoapi.adapter.AdapterSDO.importGeometry
    (AdapterSDO.java:101)
    at
    MapInfoToOracleSpatial.MapInfoToOracleSpatial.main
    (MapInfoToOracleSpatial.java:211)
    I do not have a listing of this code so can you please tell me
    what the error is (line of code) at line 211. Also, when I use
    the Oracle Spatial Index Advisor to view the spatial data, it
    only displays a quarter of the data. When I use MapInfo to view
    it's equivalent TAB (Table) file it views correctly all the
    data.
    I can't understand why this is happening because the writing to
    oracle and creation of each individual linestring does not
    throw an error. It is only when I try to read back larger
    objects from the database (2500 points) that it gives an error.
    Is there a limitation on the size one can create linestrings?
    Thanks
    Regards
    Stephen Syrett
    Mobile Telecommunications Network
    (MTN) South Africa

    Latest Oracle Openworld Spatial/MapViewer activities list:
    http://www.oracle.com/us/products/database/options/spatial/ssLINK/oow10-focuson-spatial-169204.pdf
    thanks
    LJ

Maybe you are looking for

  • How to remove duplicate entries from Settings General iTunes Wi-Fi Sync?

    On my iPhone under Settings > General > iTunes Wi-Fi Sync there is a duplicate entry for my Mac. One is active, the other one shows options greyed out, as if it can't see the Mac on the network (although it's the same name). Is there a way to manuall

  • (audio) Mirroring from Mini to Apple TV

    Why am I losing audio when mirroring to my apple TV from my computer? I can get a great image on both, but drop sound on my desktop as soon as I connect and can't even pull up audio on the TV. Then when I switch to multiple in iTunes, I drop mirrorin

  • Event only works once

    Hi all!    I'm trying to do a movieclip that has 2 buttons that change the content of a flvplayer.    The problem is that the buttons only work once, after that the event listener isn't triggered (I think) I have no removeEventListener in my code for

  • Built-in iSight not recognized by Skype!?!?!

    Bah. Just got this macbook. Running Leopard 10.5.1, etc. but Skype won't recognize my camera. Photobooth works just fine and I can see it under my system profiler. What gives?!?!

  • DELETE data issue

    hi i want to user RPUREOPN program to delete some infotype data. but i run it and get : You want to start a program which changes data without having logged on with the correct password. You have been denied authorization to do this. how to get autho