how to resolve this JDBC Error?

how to resolve this JDBC Error?

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";
        Class.forName(driverClass);
        con = DriverManager.getConnection(dburl, dbuser, dbpassword);
        if(con== null){
            System.out.println("Not Connected to DataBase");
            return;
        }
        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);
        con.close();


    }
}

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(DatabaseError.java
:112)
        at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:672)
        at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:346)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
414)
        at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:132)
        at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtensio
n.java:78)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at ConnectionDemo.main(ConnectionDemo.java:15)
View Answers









Related Tutorials/Questions & Answers:
how to resolve this JDBC Error?
errore
Advertisements
Can anybody tell me how to resolve this issue?
How to resolve NumberFormatException(Unlnown Source)?
java find the error1
java find the error4
java find the error7
java find the error3
error occured in following page ... how to resolve it?
java find the error2
errors
java find the error5
How to show all errors in PHP?
my hibernate showing the following exception so how i can resolve it
How do I resolve this Java Class not found exception?
How to validate a form in action class and forward errors to the jsp in struts?
How to resolve this error The filename, directory name, or volume label syntax is incorrect
how to display action errors in jsp which is in a form list
ModuleNotFoundError: No module named 'resolve'
Getting Exception on UseDefinedException sample program - Please help me how to resolve
check for errors
How to customize property type conversion errors in Spring MVC 3.
how to resolve the problem like when i extract the struts-blank-1.3.10.war it shows java .io.filenotfound
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'import_resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'resolve_link'
ModuleNotFoundError: No module named 'resolve-target'
how to connect mysql with JDBC - JDBC
ModuleNotFoundError: No module named 'errors'
What is the errors?
errors
Maven dependency for org.webjars.npm - resolve version 1.19.0 is released. Learn to use resolve version 1.19.0 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 0.6.3 is released. Learn to use resolve version 0.6.3 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 2.0.0-next.2 is released. Learn to use resolve version 2.0.0-next.2 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 2.0.0-next.0 is released. Learn to use resolve version 2.0.0-next.0 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 1.20.0 is released. Learn to use resolve version 1.20.0 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 2.0.0-next.3 is released. Learn to use resolve version 2.0.0-next.3 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 1.22.0 is released. Learn to use resolve version 1.22.0 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 1.22.1 is released. Learn to use resolve version 1.22.1 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 2.0.0-next.4 is released. Learn to use resolve version 2.0.0-next.4 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 2.0.0-next.1 is released. Learn to use resolve version 2.0.0-next.1 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 1.14.2 is released. Learn to use resolve version 1.14.2 in Maven based Java projects
Maven dependency for org.webjars.npm - resolve version 1.11.1 is released. Learn to use resolve version 1.11.1 in Maven based Java projects
ModuleNotFoundError: No module named 'paludis-resolve-summary'
ModuleNotFoundError: No module named 'cloud-resolve-conflicts'
ModuleNotFoundError: No module named 'pkgutil_resolve_name'
ModuleNotFoundError: No module named 'resolve-march-native'

Ads