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-813759-2002.12.27-23.46.49--gcdod-oracle#[email protected]> |
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 protected].