This discussion is archived
7 Replies Latest reply: May 3, 2013 3:30 PM by jschellSomeoneStoleMyAlias RSS

Type 1 jdbc driver conection to oracle xe in ubuntu 12.04

1006509 Newbie
Currently Being Moderated
I need help how to conect to my oracle XE in ubuntu to my program , in windows 7 i easily got conected to it thriugh user dsn but in ubuntu i am nit being able to connect it through type 1 driver .
  • 1. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    gimbal2 Guru
    Currently Being Moderated
    ok but with zero information ("it doesn't work") nobody can help you. Which driver are you using exactly, what code are you using to make the connection and which error are you getting. Use \
     tags when posting code.                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  • 2. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    rp0428 Guru
    Currently Being Moderated
    >
    I need help how to conect to my oracle XE in ubuntu to my program , in windows 7 i easily got conected to it thriugh user dsn but in ubuntu i am nit being able to connect it through type 1 driver .
    >
    If this is a JDBC issue this is the wrong forum.

    Please mark this thread ANSWERED and repost it in the Database Connectivity (JDBC) forum
    https://forums.oracle.com/forums/category.jspa?categoryID=288
  • 3. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    1003506 wrote:
    I need help how to conect to my oracle XE in ubuntu to my program , in windows 7 i easily got conected to it thriugh user dsn but in ubuntu i am nit being able to connect it through type 1 driver .
    Which means ODBC and which is a very strange choice to make with Oracle.

    Odbc works by the following path
    java -> jdbc odbc driver -> odbc shell -> odbc driver -> data base

    The last three have nothing to do with java. And unlike windows one must set up the ODBC shell and then just like windows one must then install a odbc driver (but again nothing to do with java.)

    Presumably when you say "connect" that means that in fact you have set up all of the above correctly and that you are getting a connection error. If so the type of error would tell you what type of error but it would still resolve to any normal type of connection problem such as host/port, firewall, permissions or just no connectivity.

    If you are not getting a connection error then you don't have the ODBC part set up.
  • 4. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    1006509 Newbie
    Currently Being Moderated
    I am getting folowing error:

    developer@Developer-pc:~/Desktop$ javac SelectTest.java
    developer@Developer-pc:~/Desktop$ java SelectTest
    java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver


    and my code is as like:

    import java.sql.*;
    class SelectTest
    {
    public static void main(String a[])
    {
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("Jdbc:Odbc:thin:@//localhost:1521/xe","System","system");
    Statement stmt=con.createStatement();
    ResultSet rset=stmt.executeQuery("select * from emp");
    System.out.println("Following records are selected");
    while(rset.next())
    {
    System.out.println(rset.getString(1)+"\t"+rset.getString(2)+"\t"+rset.getString(3)+"\t"+rset.getString(4));
    }
    con.close();
    }
    catch(Exception ex)
    {
    System.out.println(ex);
    }
    }
    }


    I dont know what to do next ?
  • 5. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    gimbal2 Guru
    Currently Being Moderated
    I see my comment on using \
     tags was lost on you.
    
    Your main problem is using an ODBC driver where you should be using JDBC as already stated. Any article you find on a search for "Java Oracle connect" will tell you what to do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 6. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    1006509 Newbie
    Currently Being Moderated
    I have downloaded ojdbc14.jar from oracle and placed in /usr/lib/jvm/java-6-openjdk/jre/lib/ext and added a classpath by this but same problem
  • 7. Re: Type 1 jdbc driver conection to oracle xe in ubuntu 12.04
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Shivdhwaj Pandey wrote:
    I have downloaded ojdbc14.jar from oracle and placed in /usr/lib/jvm/java-6-openjdk/jre/lib/ext and added a classpath by this but same problem
    If you are getting "java.lang.ClassNotFoundException" then it means the jar is not in the class path. Regardless of what you claim.

    If you are getting "java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver" then your code needs to be changed because the Oracle driver is not the jdbc-bridge driver. This of course also doesn't alter the fact that the jar must still be in your class path.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points