Re: Trying to connect to an Oracle db through Java, but I got this message??
"aldo" <[email protected]>
| Newsgroups | gmane.comp.db.oracle.devel |
|---|---|
| Message-ID | <LYRIS-1796914-818563-2003.01.02-10.40.56--gcdod-oracle#[email protected]> |
thank you Rouque
Yes, I can connect to the db through the SQL*+, also I have cheked the
file tnsnames, and I found out that the SERVICE_NAME=aldo.prova, thus I've
gone into the code at the line below and put aldo.prova instead of just
aldo
String sourceURL=new String("jdbc:odbc:aldo.prova");
now when I run my code I got another error message:
Java.sql.SQLException[Microsoft][ODBC Driver Manager] the source name of
the data has not been found and default driver not set???
Aldo
> 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].