This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
darine darine
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
darine darine
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic