Results 1 to 3 of 3
  1. #1
    arjun_duddu is offline Member
    Join Date
    Apr 2010
    Posts
    7
    Rep Power
    0

    Red face database Connectivity

    hiii

    please help me out i am not able to connect to Data Base: i get an Exception like:
    ORA-12514:TNS:listner could not resolve SERVICE_NAME given in connect desriptor

    DataSourceName: Oracle
    Platform:Windows XP

    my code:
    public static void main(String[] args) {

    String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    String cs="jdbc:odbc:Oracle";
    String user = "scott";
    String pwd = "tiger";
    String sqlstmt="INSERT INTO STUDENT VALUES(2,'Steve',50)";
    Connection con = null;
    Statement st = null;
    try
    {
    Class.forName(driver);
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    System.out.println("Driver loaded");
    try
    {
    con=DriverManager.getConnection(cs,user,pwd);
    System.out.println("Connected to the Oracle Database");
    st = con.createStatement();//creates a Statement object for sending SQL statements to the database.
    int updatecount=st.executeUpdate(sqlstmt);//return either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
    System.out.println(updatecount+" row inserted");
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    try
    {
    st.close();
    con.close();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }//main()
    }//class()

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default

    Hi,

    What version of Oracle database that you are using? And why are you using a JDBC ODBC bridge instead of Oracle JDBC driver?

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by wsaryada View Post
    And why are you using a JDBC ODBC bridge instead of Oracle JDBC driver?
    Yes it is, why didn't you do that?

    And also find the tnsnames.ora file in your installation file and check the settings.

Similar Threads

  1. applet with database connectivity
    By priyacvr in forum Java Applets
    Replies: 13
    Last Post: 05-06-2010, 07:44 PM
  2. Database connectivity
    By rajiparth in forum JDBC
    Replies: 1
    Last Post: 04-07-2009, 07:39 PM
  3. database connectivity
    By rilwanfit in forum Networking
    Replies: 1
    Last Post: 03-13-2009, 07:54 PM
  4. database connectivity
    By vani in forum Eclipse
    Replies: 0
    Last Post: 11-21-2008, 10:03 AM
  5. java with database connectivity
    By thamizhisai in forum New To Java
    Replies: 2
    Last Post: 04-26-2008, 10:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •