Click here to Skip to main content
12,692,778 members (33,938 online)
Rate this:
Please Sign up or sign in to vote.
See more: JDBC
i am trying to Exceute this code:
import java.sql.DatabaseMetaData;
import java.sql.Connection;
import java.sql.DriverManager; 
import java.sql.SQLException;

public class ConnectionDemo{ 
      public static void main(String args[])throws ClassNotFoundException, SQLException{
Connection con = null; 
String driverClass = "oracle.jdbc.driver.OracleDriver"; 
String dburl = "jdbc:oracle:oci:@localhost:1521:orcl"; 
String dbuser = "scott"; 
String dbpassword = "tiger"; 
con = DriverManager.getConnection(dburl, dbuser, dbpassword); 
if(con== null){ 
System.out.println("Not Connected to DataBase"); 
DatabaseMetaData dm = con.getMetaData();
String pn = dm.getDatabaseProductName(); 
String pv = dm.getDatabaseProductVersion(); 
System.out.println("Connected to : "+pn); 
System.out.println("Version of DataBase is : "+pv); 


the above programe is compiled successfully. i have also set the classpath to : ojdbc6.jar file but when i am executing this code i am getting this Error:
Exception in thread "main" java.sql.SQLException: ORA-12505: TNS:listener does n ot currently know of SID given in connect descriptor

    at oracle.jdbc.driver.DatabaseError.throwSqlException(
:112) at oracle.jdbc.driver.T2CConnection.checkError( at oracle.jdbc.driver.T2CConnection.logon( at oracle.jdbc.driver.PhysicalConnection.( 414) at oracle.jdbc.driver.T2CConnection.( at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtensio at oracle.jdbc.driver.OracleDriver.connect( at java.sql.DriverManager.getConnection( at java.sql.DriverManager.getConnection( at ConnectionDemo.main(

NOTE: i have updated my Windows XP os from microsoft website and after that i am getting this problem. prior to update my Every database programs were executing successfully but after updation of this windows i am getting this problem.
please provide me solution as soon as possible.

[Edit]Code block added[/Edit]
Posted 11-Nov-12 5:47am
Updated 11-Nov-12 5:48am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 11 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100