0

Am executing logstash JDBC config file, while executing the file am getting the below error

Error: Java::JavaSql::SQLException: 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:xe

Please find my logstash config file :

input {
  jdbc {
    jdbc_driver_library => "D:\1SearchEngine\data\ojdbc14.jar"
    jdbc_driver_class => "Java::oracle.jdbc.OracleDriver"
    jdbc_connection_string => "jdbc:oracle:thin:@localhost:1521:xe"
    jdbc_user => "ub"
    jdbc_password => "1234567"
    statement => "select * from documents"
  }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "documents"
  }
}

But am able to connect database via SQLDeveloper without any issues.

Dan Guzman
  • 43,250
  • 3
  • 46
  • 71
Karthikeyan
  • 1,927
  • 6
  • 44
  • 109
  • 1
    Try giving SID in Caps: jdbc:oracle:thin:@localhost:1521:XE – Ankit Mongia Jun 07 '18 at 18:02
  • When you connect from SQLDeveloper you pass `xe` as sid or service name? – Ivan Jun 07 '18 at 18:19
  • @Ivan i will pass `xe` – Karthikeyan Jun 07 '18 at 18:30
  • You pass it as `SID` or `Service name`? SQL developer has the following fields for connection: host, port, SID, Service name – Ivan Jun 07 '18 at 18:34
  • you might want to try jdbc:oracle:thin:@//localhost/xe as your connect string, that would be using xe as a service name instead of a sid, check this https://stackoverflow.com/questions/4832056/java-jdbc-how-to-connect-to-oracle-using-service-name-instead-of-sid – Peter M Jun 07 '18 at 18:59
  • I hope you are aware that ojdbc14.jar means that it is for Java 1.4 and that the version is probably +/- 15 years old. You should really be using a more recent driver. – Mark Rotteveel Jun 08 '18 at 07:14

1 Answers1

0

In sqldev, you can get the exact jdbc url being used. Is show jdbc in the worksheet ( or in sqlcl ). You can ensure you are connecting the same way in your logstash setup.

Here's an example. See the Driver URL line.

Also please update that driver. ojdbc8.jar is current and downloadable from http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html

SQL> show jdbc
-- Database Info --
Database Product Name: Oracle
Database Product Version: Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
Database Major Version: 12
Database Minor Version: 1
-- Driver Info --
Driver Name: Oracle JDBC driver
Driver Version: 12.2.0.1.0
Driver Major Version: 12
Driver Minor Version: 2
Driver URL: jdbc:oracle:thin:@127.0.0.1:1521:xe
Driver Location: 
resource: oracle/jdbc/OracleDriver.class
jar: /Users/klrice/workspace_commons/dbtools-commons/sqlcl/target/dbtools-sqlcl-18.1.0-SNAPSHOT-sqlcl/dbtools-sqlcl-18.1.0-SNAPSHOT/lib/ojdbc8.jar  
JarSize: 4036257  
JarDate: Thu Jan 25 14:31:44 EST 2018  
resourceSize: 2604  
resourceDate: Tue Dec 13 08:39:48 EST 2016

SQL> 
Kris Rice
  • 3,300
  • 15
  • 33