• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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){}
}
}
}
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic