After searching allot I'm still unable to connect java with oracle I used the following program.
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
public class LoadDriver{
public static void main(String[] args){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:scott/scott@localhost:1521:pdborcl");
}catch(SQLException e){
System.out.println(e.getMessage());
}catch(ClassNotFoundException e){
System.out.println("Class Not Found");
}
}
}
I'm getting error.
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:pdborcl
Because getConnection throwing SQLException
I tried all ways like jdbc:oracle:thin:@localhost:1521:pdborcl
,scott
,pass
but still unable to connect. Can any one help to connect?