This Configuration gives the output as [unable to connect to the database and no suitable driver found!], i am using logstash version 7.5.1
Asked
Active
Viewed 985 times
1
-
Try the latest version JDBC – Hariharan AR Feb 13 '20 at 05:25
-
where can i find it? – SanTiaGo KarThiCk Feb 13 '20 at 05:37
1 Answers
2
Here is the SOlved solution link for the below code. Please ref the link for more details
input {
jdbc {
jdbc_driver_library => "mongojdbc1.2.jar"
jdbc_driver_class => "com.dbschema.MongoJdbcDriver"
jdbc_connection_string => "jdbc:mongodb://DB_ADDRESS:27017/DB_NAME"
jdbc_validate_connection => true
jdbc_user => ""
clean_run => false
record_last_run => true
last_run_metadata_path => "/path/.logstash_jdbc_last_run"
schedule => "*/10 * * * * *"
jdbc_default_timezone => "YOUR_TIMEZONE"
statement =>
"
//well, actually this is JavaScript code. And was written in pure blood :(
var lastValue = :sql_last_value; //the last saved date that was scheduled to run query for
var HALF_HOUR_OFFSET = 1800000;
var extractedDate = lastValue.substring(0,10); //parsing the date of the last saved date
var year = Number(extractedDate.substring(0,4));
var month = Number(extractedDate.substring(5,7));
var day = Number(extractedDate.substring(8,10));
var extractedTime = lastValue.substring(11,23); //parsing the time of the last saved date
var hour = Number(extractedTime.substring(0,2));
var minute = Number(extractedTime.substring(3,5));
var seconds = Number(extractedTime.substring(6,8));
var miliseconds = Number(extractedTime.substring(9,12));
var upperEpoch = new Date(year,month-1,day,hour,minute,seconds,miliseconds).getTime(); //dates start from 0, that's why the minus 1
var bottomEpoch = upperEpoch - HALF_HOUR_OFFSET;
db.DB_COLLECTION.find({ COLLECTION_FIELD: { $gte : bottomEpoch, $lte: upperEpoch} },{'_id': false}); //we omit the 'id' since it irrelevant and also cause deserialize exception
"
}
}

Hariharan AR
- 1,386
- 11
- 20
-
-
-
-
yes i did now i have a unityjdbc.jar in my unity installed folder , can i have to use that jar file – SanTiaGo KarThiCk Feb 13 '20 at 05:59
-
-
yes after download i can seen unityjdbc.jar and mongodb_unity.jar which one i have to use and its a third party jar file. There is any option to use mongojdbc1.2.jar without third party like unity and progress. – SanTiaGo KarThiCk Feb 13 '20 at 06:18
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/207729/discussion-between-santiago-karthick-and-hariharan-ar). – SanTiaGo KarThiCk Feb 13 '20 at 06:24
-
-
no still i am getting a same error as no suitable driver was found but it is working in ubuntu perfectly using mongojdbc1.6.jar not wokring in windows – SanTiaGo KarThiCk Feb 13 '20 at 11:35