Re: Trying to connect to an Oracle db through Java, but I got this message??

Roque Daudt <[email protected]>
Newsgroups gmane.comp.db.oracle.devel
Message-ID <LYRIS-1796914-814866-2002.12.29-02.18.35--gcdod-oracle#[email protected]>
ORA-12514 means that a Net8 client was unable to create a connection to
a database. Net8 clients try to create connection with basis on the
tnsnames.ora file's content. Have you checked this file? Are you able
to establish a db connection using any other tool - like Oracle
SQL*Plus?

Roque Daudt

--- aldo <[email protected]> wrote:
> Hi, I tried to connect to an Oracle database whose SID is called Aldo
> on 
> my local machine called (server) on a WIN 2000 plattaform.
> 
> I have set the ODBC driver under Win 2000 as described on the
> paragraph: 
> Setting up a Database page 1015 of Beginning Java2 jdk1.3 on System
> DSN: 
> the name source data is aldo, the user name: SYSTEM, the Server:
> server,
> but when I run the MakingAStatement.java  under JBuilder6 I got this 
> message or error, why???:
> 
> 
> C:\JBuilder6\jdk1.3.1\bin\javaw -classpath "C:\JBuilder6
> \samples\Welcome\classes;C:\JBuilder6\jdk1.3.1
> \demo\jfc\Java2D\Java2Demo.jar;C:\JBuilder6\jdk1.3.1
> \jre\lib\i18n.jar;C:\JBuilder6\jdk1.3.1\jre\lib\jaws.jar;C:\JBuilder6
> \jdk1.3.1\jre\lib\rt.jar;C:\JBuilder6\jdk1.3.1
> \jre\lib\sunrsasign.jar;C:\JBuilder6\jdk1.3.1\lib\dt.jar;C:\JBuilder6
> \jdk1.3.1\lib\htmlconverter.jar;C:\JBuilder6\jdk1.3.1\lib\tools.jar" 
> 
> MakingAStatement 
> java.sql.SQLException: [Microsoft][ODBC driver for
> Oracle][Oracle]ORA-
> 12514: TNS:listener could not resolve SERVICE_NAME given in connect 
> descriptor
> 
> 
> the code of the java program whether you are interested in is:
> 
> 
> import java.sql.*;
> public class MakingAStatement
>  {
>   public static void main(String[]args)
>   {
>    //Load the driver 
>    try
>     {
>      //Load the driver class
>      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>      
>      //This defines the data source for the driver
>      String sourceURL=new String("jdbc:odbc:aldo");
> 
>     //Create connection through the DriveManager
>     Connection databaseConnection=
>                        DriverManager.getConnection(sourceURL);
>    Statement statement=databaseConnection.createStatement();
>    
>    ResultSet authorNames= statement.executeQuery
>                           ("SELECT lastname, firstname FROM
> authors");
> 
>    // Output the resultset data
>     while(authorNames.next())
>     System.out.println(authorNames.getString("lastname")+" "+
>      authorNames.getString("firstname"));
>     }
>     catch(ClassNotFoundException cnfe)
>     {
>      System.err.println(cnfe);
>     }
>     catch(SQLException sqle);
>     {
>      System.err.println(sqle);
>     }
>    }
>   }
> 
> Thanks in advance
> Aldo
> 
> 
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or 
> to unsubscribe send a blank email to
%%email.unsub%%.


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to [email protected].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.