Mongo DB: Iterate through a MongoCollection

This is specifically for Mongo 3.x, where MongoCollection is preferred over DBCollection. Adding for personal archiving.


MongoCollection<Document> mongoCollection =
            getMongoCollection(databaseName, collectionName);

        FindIterable<Document> documents =
            mongoCollection.find(eq(COLUMN, "lastName"))
                .sort(ascending("lastname"));

        for (Document document : documents) {
            ...
        }

Oracle: How to select less or greater than with dates

Coming from a Microsoft/SQL Server world but now into Open Source/Oracle, I didn’t know what the syntax was, so here’s how:

select * from table where column < to_date(‘6/21/2014 21:50:0′,’mm/dd/yyyy HH24:MI:SS’);

select * from table where column > to_date(‘6/21/2014 21:50:0′,’mm/dd/yyyy HH24:MI:SS’);

Hope this helps someone out there.  Cheers!

soapUI Error: “ERROR:com.eviware.soapui.support.SoapUIException: Failed to init connection for drvr [oracle.jdbc.driver.OracleDriver]

I was encountering the following error in soapUI when one of the test steps was to check the database.

com.eviware.soapui.support.SoapUIException: Failed to init connection for drvr [com.microsoft.sqlserver.jdbc.SQLServerDriver], connectionString [jdbc:sqlserver://server:port;databaseName=DB name;user=username;password=#####] 

The issue was because my soapUI installation didn’t have the appropriate ODBC jar file. 

1. Get it from Oracle

2. Place it in your $SOAPUI/bin/ext folder

3. Restart soapUI

4. That’s it!

Reset MySQL Password on OS X Lion

In case you forgot or didn’t set the password for “root,” do the following:

1. Create a file called mysql-init with the following entries (I placed mine in my home directory):

UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass’) WHERE User=’root’;
FLUSH PRIVILEGES;
2. Make sure mysqld is not running (i.e. terminal > ps -ef | grep mysql)

3. Run mysql with the following command:

mysqld_safe –init-file=/home/me/mysql-init &

4. Try logging in with root: mysql -u root -p

5. You can now delete mysql-init and start mysql in the normal way: mysql.server start

Note: I tried mysqld –skip-grant-tables, but it didn’t work for me.