File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes  ORA-12514: TNS:listener could not resolve SERVICE_NAME given? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark " ORA-12514: TNS:listener could not resolve SERVICE_NAME given?" Watch " ORA-12514: TNS:listener could not resolve SERVICE_NAME given?" New topic
Author

ORA-12514: TNS:listener could not resolve SERVICE_NAME given?

darine darine
Ranch Hand

Joined: Mar 08, 2001
Posts: 43
Hi All
I got the following error(the title message)
what is the problem plz?
===============================
import java.sql.*;
import java.util.*;
public class attemptConnection_Without_ClassForName
{
public static void main(String arg[])
{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
//String sqlStatement="select check_number,posting_date,amount,transaction_number from checkInfo";
String sqlStatement="SELECT * FROM checkInfo where posting_date="+"'"+"28-JAN-2001"+"'";
try
{
//Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

con = DriverManager.getConnection("jdbc racle ci8:@localhost","db2admin","db2admin");
stmt = con.createStatement();
rs = stmt.executeQuery(sqlStatement);
while(rs.next())
{
System.out.println(rs.getInt("check_number") + " "+rs.getDate("posting_date") +" "+rs.getInt("amount")+" "+rs.getInt("transaction_number"));
}
}
/*
catch(ClassNotFoundException e)
{
System.out.println("Couldn't load database driver: " + e.getMessage());
}
*/
catch(SQLException e)
{
System.out.println("SQLException caught: " + e.getMessage());
}
finally
{
try
{
if(con != null) con.close();
}
catch(SQLException ignored){}
}
}
}
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Does it work for the Class.forName()?
con = DriverManager.getConnection("jdbc racle ci8:@localhost","db2admin","db2admin");

so you are running personal Oracle? I see localhost, so you must be using the default port 1521, but after that I do not see your Oracle Sid.
Using the OCI driver means you are using Oracle Client, which has your tnsnames.ora file with the Sid name in it.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
darine darine
Ranch Hand

Joined: Mar 08, 2001
Posts: 43
thanks for the reply.
yes it does not work with Class.forName()
also when i use the port 1521 i get the following message: " ORA-06401: NETCMN: invalid driver designator "
any idea?
thanks again.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

error ORA-12514 is equivalent to this:
TNS-12514 TNS:listener could not resolve SERVICE_NAME given in connect descriptor
Cause: The SERVICE_NAME in the CONNECT_DATA was not found in the listener's tables.
Action: Check to make sure that the SERVICE_NAME specified is correct.
you can look up your own error messages at the Oracle site
this link on connecting to Oracle may help.
I have also posted a pretty extensive list of Oracle/jdbc resources
in this post.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ORA-12514: TNS:listener could not resolve SERVICE_NAME given?