Connecting JDBC-ORACEL database using type 3 thin driver.

I'm new in Java. Could someone please send me the source code how to connect to remote oracle database with jdbc using Type 3 driver. I'm sure millions of people have already done this. I will appreciate if anyone could help me.

Have you written any Java or done JDBC before? I don't mean to insult you if you have, but look in any JDBC book or the Java Tutorial and you'll see how to connect to a database:
Class.forName("fullyResolvedJdbcDriverClassName");
Connection connection = DriverManager.getConnection("databaseURL");
Gotta put the JDBC driver class in your CLASSPATH somewhere.
Gotta follow the directions for your database URL to the letter.
But if you do all that, it should work.
Oracle and Type 3 won't change any of this. Personally, I connect to Oracle using the Type 4 thin driver. Why are you using Type 3?
Did you look at the JDBC tutorial on-line? Sun has great materials there. Have you checked any of that out? - MOD

Similar Messages

  • How to connect to personal oracle using oracle thin driver on windows98

    Hi,
    i would like to know is it possible to connect to personal oracle8 using oracle thin driver on windows98.iam getting some exceptions when iam running ,could any one help me
    1.exception in thread main java.sqlexception:IOexception:the
    networkadapter could not establish the connection
    2.at oracle.jdbc.dbaccess.DBError.throws sqlexception(DBError.java)
    3.atoracle.jdbc.dbaccess.DBError.throws sqlexception(DBError.java)
    4.atoracle.jdbc.driver.oracleconnection.<init>(oracleconnection.java)
    5.atoracle.jdbc.driver.oracledriver.getconnectioninstance(oracledrive
    r.jva)
    6.atoracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
    7.atjava.sql.DriverManager.getConnection(unknown source)
    8.atjava.sql.DriverManager.getConnection(unknown source)
    9.at JEmp.main(JEmp.java:16)
    null

    http://www.orafaq.com/wiki/JDBC#Thin_driver

  • Jdbc connectivity using type 4 driver using oracle10g

    Hi while running a jdbc program using type 4 driver using oracle 10 g I am Getting following exception
    java.lang.NullPointerException
    java.lang.NullPointerException
    at Type4ConnectTest.main(Type4ConnectTest.java:31)
    Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.
    OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at Type4ConnectTest.main(Type4ConnectTest.java:15)
    My Program Code is..
    import java.sql.*;
    class Type4ConnectTest
    public static void main(String args[])throws Exception
    Connection con=null;
    Statement st=null;
    ResultSet rs=null;
    try
    // DriverManager.registerDriver(new Oracle:jdbc:OracleDriver());
    Class.forName("oracle.jdbc.OracleDriver");
    String url="jdbcracle:thin:@localhost:1521";
    con=DriverManager.getConnection(url,"sarika","sarika");
    catch(NullPointerException e)
    System.out.println("e");
    e.printStackTrace();
    finally
    try
    con.close();
    st.close();
    rs.close();
    catch(Exception e)
    System.out.println(e);
    e.printStackTrace();
    I also set path of ojdbc14.jar and orai18n.jar in environment variable.
    pls help to solve the problem

    Class.forName("SOME_DRIVER_CLASS");Is tricky to use because it will compile not needing to reference the vendors jar file.
    You have to remember to deploy it though where ever you plan to run this program.
    If you are running from command line
    java -cp PATH_TO_JAR Type4ConnectTest

  • Jdbc connection using oracle thin driver( using jdk1.4 and oracle8 )

    hello ..
    while i was tring to connection using oracle thin driver and jdk1.4 am getting the below error message. i have set the class path for the driver also. am using oracle8 personal edition and jdk1.4.
    [java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
            at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
            at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:468)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
            at java.sql.DriverManager.getConnection(DriverManager.java:512)
            at java.sql.DriverManager.getConnection(DriverManager.java:171)
            at Connexa.main(Connexa.java:18)[/b]
    Press any key to continue...
    my program is....
    import java.sql.*;                                          
    import java.io.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    // needed for new BFILE class
    import oracle.sql.*;
       public class Connexa {
      public static void main (String args []) throws Exception {
            Statement stmt=null; 
      try{
        // Load the Oracle JDBC driver                            
        //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Class.forName("oracle.jdbc.driver.OracleDriver");
        // Connect to the database
        // You can put a database name after the @ sign in the connection URL.
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","scott","tiger");
        //Connection conn =
        //  DriverManager.getConnection ("jdbc:odbc:datasource", "system", "manager");
        stmt = conn.createStatement ();
    catch (SQLException e)
          e.printStackTrace();

    The code itself is fine; the problem is with one of:
    1) the connection URL
    2) intermediate networking
    3) the database itself
    1) your connection URL is "jdbc:oracle:thin:@127.0.0.1:1521:orcl"
    - is Oracle really running on the default port, 1521
    - is the installation SID really "orcl"
    2) lots of possibilities, but only a couple are likely
    - is TCP/IP configured and running on your host
    - is there a persoanl firewall rpduct running? perhaps it's blocking the connection
    3) Is Oracle running?
    Is the listener running?

  • Error in creating Connection Pool using Oracle Thin Driver

    Hi,
    I am trying to create a connection pool in WS 5.1 with sp #6 using Oracle Thin Driver (oracle.jdbc.driver.OracleDriver) on a Sun box. But I am able to create the pool using weblogic.jdbc.oci.Driver. I get an DBMS Driver exception when I use thin driver. I have LD library path and weblogic class path set correctly. WL shows the following exception :
    weblogic.common.ResourceException: weblogic.common.ResourceException:
    Could not create pool connection. The DBMS driver exception was:
    java.sql.SQLException: Io exception: The Network Adapter could not establish the
    connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
    Any help on this is greatly appreciated.
    Thanks,
    Ramu

    Hi Ramu,
    Please post your connection pool setting here. You might have missed some
    port/server info. The driver is unable to connect to the db server here.
    sree
    "Ramu" <[email protected]> wrote in message
    news:3d5bbc3a$[email protected]..
    >
    Yes. I am trying to create a connection pool in weblogic and I have theweblogic
    class path setup correctly. It points to classes111.zip andnls_charset11.zip.
    >
    -Ramu
    "Neo Gigs" <[email protected]> wrote:
    Did you setup the JDBC library classpath correctly?
    For me, e.g. Oracle 7.3.4, the classpath should be:
    export CLASSPATH = /oracle7.3.4/jdbc/lib/classes.zip:%CLASSPATH%
    Noted that the JDBC classpath must be the first classpath element in
    the export
    statement.
    Neo

  • Connection using type 4 driver

    Hi,
    We are using type 4 driver to connect to Oracle.
    I am getting an exception as
    "com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of CWD".
    Can anyone tell me the reason and how to solve it?

    This s my code:-
    try
            InitialContext ic = new InitialContext();
         DataSource ds = (DataSource)ic.lookup("jdbc/CWD");
         con=ds.getConnection();
         st = con.prepareStatement("select desig from Users where username like cusername and cpassword like password");
            rs = st.executeQuery();
            String desig=null;
            while(rs.next())
                 desig=rs.getString("desig");
                 if(desig.equals("admin"))
                        wdThis.wdFirePlugToadminview();
       else if(desig.equals("customer"))
                            wdThis.wdFirePlugTouserview();
                 else
                        wdComponentAPI.getMessageManager().reportSuccess("Invalid Username/Password");
       catch(Exception e)
       {wdComponentAPI.getMessageManager().reportException(e.toString(),true);}
       finally
            try
                 rs.close();
                 st.close();
                 con.close();
            catch(Exception e)
    can u pls tel me wht is the problem?

  • Not able to connect to database using Oracle ODBC Driver

    Hi,
    I have installed Oracle client on a system. there are 2 homes installed. When I check the ODBC administrator, I see that only one ODBC driver is present. There are Net 8 services configured in both the homes.
    When I try to connect to a database with the services configured in the second home using the ODBC driver, I am getting an error that the TNS name could not be resolved.
    How can I use the ODBC driver to connect to the databases using services defined in the second home?
    The name of the ODBC driver is 'Oracle in <firsthomename>
    Thanks & Regards

    Hi,
    Thanks for the help.
    I tried this, but it doesn't work. I'm still getting the error.
    Now I am not able to create a DSN when I set the ORACLE_PATH to the second home. It says 'the setup routines for the Oracle in ora1 ODBC Driver could not be loaded due to system error code 998.'
    Any other solution?
    Thanks in advance & Regards
    Anuja

  • GUYS!! Is there any way to write BLOB's 4K using Oracle thin driver

    I've been trying for 3 days to do that but nothing worked ...
    Not
    setBinaryStream(x, new ByteArrayInputStream(anArrayWith10KBytes), anArrayWith10KBytes);
    nor setBytes(x, myArray), or setObject(x, myArray).
    Is there any way to store Blobs to Oracle 8.1.6 using the thin driver ????????????
    Please help ... cause I really need it !!!
    Best regards,
    Stefig

    Hi Stefig
    Following code help you to store the files >4k in BLOB column in Oracle database
    test is a table in which TEST is BLOB column
    String url = "jdbc:oracle:thin:@.....";
    String user = "user name";
    String password = "password";
    Connection conn = null;
    PreparedStatement aQuery = null;
    ResultSet rs = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection(url,user,password);
    conn.setAutoCommit(false);
    Statement stmt = conn.createStatement();
    stmt.execute("insert into test values (EMPTY_BLOB())");
    rs = stmt.executeQuery("select TEST from test");
    rs.next();
    BLOB blob =((OracleResultSet)rs).getBLOB(1);
    File f = new File(filename);
    FileInputStream io = new FileInputStream(f);
    OutputStream os = blob.getBinaryOutputStream();
    int size = io.available();
    byte[] buffer = new byte[1024];
    int length=0;
    while((length=io.read(buffer)) != -1)
    os.write(buffer,0,length);
    io.close();
    os.close();
    stmt.execute("commit");
    catch()
    Good Luck
    From
    Sachin

  • Using oracle thin driver from Weblogic server 6.1

    Hi
    I need to know which driver is best for establishing JDBC Connection i.e.
    whether to use JDriver provided with Weblogic or to go using Oracle thin driver.
    Can some one tell the detailed procedure involved in configuring oracle thin driver
    in Weblogicserver 6.1.
    Thanks in advance,
    S Gopikrishna

    I would recommend using the thin driver where ever possible, their are
    certain problems with thin driver which are more in the area of XA support
    you can check weblogic documentation for pointers on this. Oracles latest
    thin driver is pretty stable as they have fixed a bunch of problems.
    heres how to use thin driver:
    create the connection pool using the following url
    jdbc:oracle:thin:@<mc-name or ip-address>:<port-no>:<oracle sid>
    and driver: oracle.jdbc.driver.OracleDriver
    You dont have to install the thin driver its bundled with the product.
    hth
    sree
    "S Gopikrishna" <[email protected]> wrote in message
    news:3c34a0e5$[email protected]..
    Hi
    I need to know which driver is best for establishing JDBC Connection
    i.e.
    whether to use JDriver provided with Weblogic or to go using Oracle thin
    driver.
    Can some one tell the detailed procedure involved in configuring oracle thin
    driver
    in Weblogicserver 6.1.
    Thanks in advance,
    S Gopikrishna

  • Using oracle thin driver

    Hi,
    I have a problem in using oracle thin driver,ive downloaded oracle thin driver and classpath has been set for classes12.zip.Iam trying to connect to server:teams sid:teams .
    the following code compiles and throws error @ runtime
    ************************ code****************8
    import java.sql.*;
    public class ocdtest {
    public static void main(String arg[]){
    try {
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@teams:1521:teams", "raghu", "startoracle");
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("select login_name from login");
    while (rset.next ()){
    System.out.println (rset.getString ("login_name"));
    }catch(Exception e){
    System.out.println(e);
    ********************* code *********************************
    ********************** Exception *************************
    Exception in thread "main" java.lang.UnsatisfiedLinkError: get_env_handle
    at oracle.jdbc.oci8.OCIEnv.get_env_handle(Native Method)
    at oracle.jdbc.oci8.OCIEnv.getEnvHandle(OCIEnv.java:70)
    at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:359)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:252)
    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:512)
    at java.sql.DriverManager.getConnection(DriverManager.java:172)
    at ocdtest.main(ocdtest.java:11)
    *******************************Exception **********************
    can anyone help me how to solve this problem.
    thanks in advance
    karthik

    Hi,
    The following code works
    import java.sql.*;
    public class ocdtest {
    public static void main(String arg[]){
    try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection("jdbc:oracle:thin:@teams:1521:teams", "raghu", "startoracle");
              Statement s=con.createStatement();
              System.out.println("connected");
              ResultSet rs=s.executeQuery("select login_name from login where login_name='tom'");
              System.out.println("resultset");
              while(rs.next()){
                   System.out.println(rs.getString("login_name"));
    }catch(Exception e){
              System.out.println(e);
    all u need to download is classes12.zip and the patch for this zip .
    thanks and regards
    Karthik

  • Unable to connect to Oracle Database using Oracle Sql developer 2.1.1.64

    Hi Everyone,
    I am searching for some help regarding my problem with Oracle connectivity. I have installed Oracle 11g release 2 on my Windows XP Professional Laptop. For a few days after installation i could connect to the Oracle database with the SYSTEM account using Oracle SQL developer ( installed on the same Laptop) but now i am unable to do so.It gives me this annoying message:
    An error was encountered performing the required operation  Got a minus one from read call .Vendor code 0
    However i am able to connect using Sql Plus by supplying the username SYSTEM and the corresponding password.
    My TNSNAMES .ora file is as follows:
    ORACLE =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = ORACLE)
    ORACLR_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (CONNECT_DATA =
    (SID = CLRExtProc)
    (PRESENTATION = RO)
    My Listener.ora file is as follows:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = CLRExtProc)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ONLY:D:\app\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    (SID_DESC =
    (GLOBAL_DBNAME = Oracle)
    (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
    (SID_NAME = Oracle)
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (PROTOCOL_STACK =
    (PRESENTATION = GIOP)
    (SESSION = RAW)
    ADR_BASE_LISTENER = D:\app
    My Sqlnet.ora file is as follows:
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
    I am new to Oracle and so i need someone in this forum who can help me resolve this problem. Also i even tried connecting to the database using Toad 10.5.0.41. It give me the following error:
    ORA 12537 : TNS Connection closed
    Thanks for your patience and help in advance.
    ---Prashant

    Hello Irian and Sue,
    I can connect to the Oracle database using SQL Plus. Now when i TNSPING ORACLE from command line i get the following message :
    Used parameter files:
    D:\app\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =localhost
    *)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORACLE)))*
    TNS-12537: TNS:connection closed
    Thanks for your response to my initial post.Do u have any other methods to resolve this?

  • How can I connect to the database using ODBC within excel.

    Hi,
    How can I connect to the database using ODBC within excel and just refresh the data when needed.
    Thanks,
    Priyanka
    Edited by: user554934 on Jun 9, 2009 2:53 AM

    This is NOT an APEX relevant question, try posting it in the SQL/PL/SQL Forum..
    Thank you,
    Tony Miller
    Webster, TX

  • Using oracle thin driver with to_char gives invalid column name

    select x,y,z, to_char(event_time,'YYYY-MMM-DD') from eventtable;
    if i execute the above query using oracle thin driver it gives me invalid column name. It works fine if i use weblogic driver. So what could be the problem ???
    thanks.

    Sorry , forgot to add that 'YYYY-MM-DD' or 'YYYY-Month-DD' or 'Year-MM-DD' or 'Year-Month-DD' are also allowed(please cheek also for other combinations), not 'YYYY-MMM-DD'.
    Thanks

  • Connection to multiple databases using a single EJB

    How can I connect to multiple Databases (using @PersistenceContext) using an EJB?
    Did I need to connect various Entity Managers corresponding to the each database and simply send my Queries?
    I am using Glassfish Application Server
    Netbeans IDE
    Java Derby Database
    Oracle Database
    Java Persistence API
    Thanks in Advance

    Yes, you need a persistence context and thus entity manager per database. Depending on what you want to achieve you may also need to go to the next level in your skill set and learn all about distributed transactions.

  • Connect to oracle database using c program

    I am using AIX environment and i want to connect to oracle database using c program.

    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10825/pc_03dbc.htm#i5880

Maybe you are looking for

  • Need to function module to clear Subscreen contents

    Hi. can anyone say Function module which clears the contents of Subscreen when navigated from subscreen to subscreen. MY Problem: i have 6 subscreen.(A,B,C,D,E,F) each subscreen has 100 checkboxes. i checked some checkboxes of subscreen A. And naviga

  • Problem In Executing Query In JSP-Oracle

    I have one Query with some conditions in it. It showing error in JSP page when Run it like FROM keyword not found where expected, but this query running well in Oracle SQL Developer. The query is given below. SELECT SCC.STACK_ID, S.SEVERITY_LOWER AS

  • Use of J1I5- Regester update

    Hello CIN guru's Can anyone explain me the use of T code J1I5- Regester Update in CIN module, i concern is when i have already posted the GR and Excise invoice is it really required to again update the regester. when do we use J1I5. Suggestions worth

  • Trying to print one page of a document in duplex - help!

    Hi, I've done a fair bit of work generating postscript from an OpenVMS COBOL system in the past, and while not an expert, have usually managed to produce something that works. This time I'm failing. Can anyone assist. The problem: I have a document w

  • Strange error when releasing CR to QA

    In CHARM, I try to release a tp CR to QA. The steps are as follows: go txn crm_dno_monitor double click the CR that should be released to the QA select the action "pass correction to test" Then it fails with message as follows: Action Release Transpo