Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Exception in thread "main" java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  2. The Connection descriptor used by the client was:localhost:1521:orcl
  3.  
  4. at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
  5. at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
  6. at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
  7. at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
  8. at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
  9. at oraenter code herecle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
  10. at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
  11. at java.sql.DriverManager.getConnection(DriverManager.java:582)
  12. at java.sql.DriverManager.getConnection(DriverManager.java:185)
  13. at com.test.Date.main(Date.java:13)
  14.  
  15. Class.forName("oracle.jdbc.driver.OracleDriver");
  16. Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger");
  17.  
  18. ORCL =
  19. (DESCRIPTION =
  20. (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  21. (CONNECT_DATA =
  22. (SERVER = DEDICATED)
  23. (SID = orcl)
  24. )
  25. )
  26.  
  27. try {
  28. Class.forName("oracle.jdbc.OracleDriver");
  29. } catch (ClassNotFoundException e) {
  30. e.printStackTrace();
  31. return;
  32. }
  33. Connection con = null;
  34. try {
  35. con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger");
  36. } catch (SQLException ex) {
  37. ex.printStackTrace();
  38. } finally {
  39. close(connection);
  40. }
  41. return
  42.  
  43. jdbc:oracle:thin:@//localhost:1521:orcl","system","tiger
  44.  
  45. jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=<host>)(PORT=<port>))(CONNECT_DATA=(SERVICE_NAME=<service>)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement