|
| 1 | +For testing purposes, you can generate a self-signed certificate and private key on a |
| 2 | +Unix system with a command that resembles the following: |
| 3 | +cd /etc/ssl/ |
| 4 | +openssl req -new -x509 -days 365 -nodes -out mongodb-cert.crt -keyout mongodb-cert.key |
| 5 | + |
| 6 | +This operation generates a new, self-signed certificate with no passphrase that is valid for 365 days. |
| 7 | +Once you have the certificate, concatenate the certificate and private key to a .pem file, |
| 8 | +as in the following example: |
| 9 | +cat mongodb-cert.key mongodb-cert.crt > mongodb.pem |
| 10 | + |
| 11 | +given an SSL certificate located at /etc/ssl/mongodb.pem, configure mongod to use SSL encryption |
| 12 | +for all connections with the following command: |
| 13 | +mongod --sslMode requireSSL --sslPEMKeyFile /etc/ssl/mongodb.pem |
| 14 | + |
| 15 | +To connect to a mongod or mongos instance that requires only a SSL encryption mode, |
| 16 | +start mongo shell with --ssl, as in the following: |
| 17 | + |
| 18 | +mongo --ssl |
| 19 | + |
| 20 | +To connect to a mongod or mongos that requires CA-signed client certificates, |
| 21 | +start the mongo shell with --ssl and the --sslPEMKeyFile option to specify the signed certificate-key file, |
| 22 | +as in the following: |
| 23 | +mongo --ssl --sslPEMKeyFile /etc/ssl/client.pem |
| 24 | + |
| 25 | +Jasper Query |
| 26 | +------------ |
| 27 | +-- Select all |
| 28 | +{ |
| 29 | + 'collectionName' : 'accounts' |
| 30 | +} |
| 31 | + |
| 32 | +-- Specify the fields returned and sort the results |
| 33 | +{ |
| 34 | + 'collectionName' : 'accounts', |
| 35 | + 'findFields' : { |
| 36 | + 'name':1, |
| 37 | + 'address.zip':1, |
| 38 | + 'phone_office':1, |
| 39 | + 'billing_address_city':1, |
| 40 | + 'billing_address_street':1, |
| 41 | + 'billing_address_country':1 |
| 42 | + }, |
| 43 | + 'sort' : { |
| 44 | + 'billing_address_country':-1, |
| 45 | + 'billing_address_city':1 |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +-- Filtered and parameterized |
| 50 | +{ |
| 51 | + 'collectionName' : 'accounts', |
| 52 | + 'findQuery' : { |
| 53 | + 'status_date' : { '$gte' : $P{StartDate}, $lt: $P{EndDate} }, |
| 54 | + 'name' : { '$regex' : '^N', '$options' : '' } |
| 55 | + |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +-- $in clause |
| 60 | +{ |
| 61 | + 'collectionName' : 'customers', |
| 62 | + 'findQuery' : { 'industry' : { '$in' : ['Communications','Engineering'] } } |
| 63 | +} |
| 64 | + |
| 65 | +-- map reduce |
| 66 | +{ |
| 67 | + 'collectionName' : 'customers', |
| 68 | + 'findQuery' : { 'industry' : { '$in' : $P{MyCollectionParameter} } } |
| 69 | +} |
| 70 | + |
| 71 | +-- aggregation |
| 72 | +{ |
| 73 | + runCommand: { |
| 74 | + aggregate : 'zips', |
| 75 | + pipeline : [ |
| 76 | + { |
| 77 | + $group : { |
| 78 | + _id : '$state', |
| 79 | + population: { |
| 80 | + $sum : '$pop' |
| 81 | + } |
| 82 | + } |
| 83 | + }, |
| 84 | + { |
| 85 | + $sort : { |
| 86 | + population : -1 |
| 87 | + } |
| 88 | + } |
| 89 | + ] |
| 90 | +} |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +MongoDB with Java |
| 95 | +------------------ |
| 96 | + |
| 97 | +1. Download JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html |
| 98 | +2. Install the same |
| 99 | +3. Open command prompt and type: java -version. This should check the proper installation. |
| 100 | +4. Download eclipse from https://www.eclipse.org/downloads/ |
| 101 | +5. Install eclipse |
| 102 | +6. Download mongodb-java driver from https://github.com/mongodb/mongo-java-driver/downloads |
| 103 | +7. Open eclipse and workspace |
| 104 | +8. Create a java project |
| 105 | +9. Create a java project and add the above jar in the class path |
| 106 | + |
| 107 | +Please share your review |
| 108 | +------------------------ |
| 109 | +http://www.quora.com/Reviews-of-Edureka-online-education |
| 110 | + |
0 commit comments