MySQL Failed to open file – error 2 and 22 on Windows

I recently had to restore a MySQL backup. It had been a while since I used MySQL, having switched to Postgresql sometime back. First thing I noticed was the lack of a GUI admin tool that PG spoils you with. Making matters worse, the command line tool isn’t even added to your path; you can’t just run “mysql” like you can in a Unix shell, much less use the redirect shortcut. And I was getting errors.

Here’s what you need to do to restore a MySQL backup on Windows:

  1. Run the command line tool from the start menu
  2. Open your backup file in a text editor. Does it start with a command to create or “use” the database? If not
    1. Create it, if necessary
    2. Type “use database” filling in your DB name
  3. Type “source path-to-SQL-file“. BUT, you must follow these rules:
    1. Use the full source command, not the \. shortcut
    2. Have no spaces in your path. I copied mine to a root of a drive. Note that spaces in the file name is OK, just not the path.
    3. Do not quote the file name, even if it has spaces. This gave error 22.
    4. Use forward slashes in the path, e.g., C:/path/to/filename.sql. Otherwise you’ll get error 2.
    5. Do not end with a semicolon.

Follow all those rules and it should work fine.

Companies Using Grails

Companies Using Grails

I’m pretty excited about Grails, but am often asked for social proof. Well, by every measure,1 Groovy is the #1 JVM language after Java, and Grails is the #1 full stack web framework.2 But for some, that’s not enough. They want to know who is making it #1? Major companies. Below I’ve listed the household names. I could not get details for some companies, but a Google search will verify the claim (e.g., the Disney developer posting a Grails question to a mailing list).

Last update: August 20th, 2015

Entertainment/Gaming

  • DISH
  • Disney
  • Epic Games
  • ESPN
  • Industrial Light & Magic
  • LiveNation – TicketWeb
  • Live Gamer
  • Lucasfilm
  • MTV (and Viacom by extension)
  • NBC Universal
  • Netflix – Asgard, their Amazon EC2 cloud management app, now open sourced.
  • Riot Games (makers of League of Legends)
  • Rumble Entertainment (maker of Kings Road)
  • Time Warner Cable

Finance

  • American Express
  • Bank of the West
  • Citi
  • Credit Suisse
  • Federal Reserve Bank of San Francisco
  • Federal Reserve Bank of Kansas City
  • Fidelity Investments
  • First Data Corporation
  • Freddie Mac
  • H&R Block – mobile site (now defunct)
  • Intuit – Intuit Payment Network
  • Janus
  • JPMorgan Chase
  • MoneyGram
  • OppenheimerFunds
  • PayPal – Bill Me Later
  • UBS Wealth Management
  • Visa
  • Wells Fargo

Retail/Ecommerce

  • 7-11 (back office systems)
  • Big Lots – core site
  • Jostens
  • Macy’s
  • Nordstrom (HauteLook)
  • Panera Bread
  • Target
  • Walmart – MP3 streaming site (now defunct)

Tech

  • Apple
  • Atlassian
  • Cloudera
  • CollabNet – web interface to SVN server
  • CyberSource
  • Dell – Enstratius
  • Ericsson
  • HP – Application Information Optimizer
  • IBM – Kenexa
  • IEEE
  • Infusionsoft
  • Intel – New Devices Group
  • Nokia
  • Qualcomm
  • Rackspace
  • Rally Software
  • Seagate
  • Symantec
  • T-Mobile – internal apps
  • Toshiba- Toshiba America Business Solutions

Other

  • CARFAX
  • Commission Junction (part of Conversant)
  • Condé Nast
  • eHarmony
  • GEICO – mobile web
  • HealthPartners – Virtuwell
  • Humana
  • Infusionsoft
  • Jet Propulsion Laboratory
  • Johnson & Johnson
  • LifeLock
  • LinkedIn – Recruiter application
  • Lockheed Martin
  • Lyris
  • NetJets
  • Nissan – Leaf site
  • Orbitz
  • Pacific Gas and Electric Company
  • Precor – Preva product
  • Raytheon
  • ReachLocal
  • Reinsurance Group of America
  • Time Inc.
  • Trip Advisor
  • UnitedHealth Group
  • ValueClick
  • Virtual Tourist – core site (parent is Trip Advisor)
  • Volkswagen – UK site
  • The Washington Post
  • Wired.com
  • The XO Group (parent of The Knot / WeddingChannel.com)
  • Zynx Health (Hearst Health Group)
These are household names in some countries outside the US:
  • MACSF – (France) insurance company, internal systems
  • Mercado Libre – (South America) core site
  • National Film Board of Canada
  • Sky – (UK) TV listings, movies, and showbiz sites
  • Vodafone Music – (UK) core site
Colleges and universities:
  • Carnegie Mellon University
  • Colgate University
  • Columbia University
  • Harvard University
  • NYU (Langone Medical Center)
  • SUNY
  • UCSF
  • University of Alaska
  • University of California, Irvine
  • University of Hawaii
  • University of Minnesota
  • University of New Mexico
  • University of Oklahoma
  • University of Pennsylvania
  • University of San Francisco
  • Yale University

There are lists of many lesser known companies/apps found here and here.3 Another good place to check is Find Grails Jobs and indeed.com. I used all of them to compose this piece.

  1. Tiobe, job listings, etc. []
  2. Granted, I can only think of 3 others, Play, Roo, and Seam, but full stack is where you get the most productivity. []
  3. Apologies in advance that I’m intentionally leaving off startups and smaller companies. That’d be too much to manage and it won’t sway managers and architects, which is the point of this piece. []

Merging XML Files With Groovy

I needed to generate an XML file from database tables and the plan was to use Talend Open Studio. Talend is an ETL tool that generates data integration jobs in Java. The community edition is free and I’d been using it for several other data tasks for an ecommerce client. Overall, I think it’s quicker than hand coding in Java, but you can still dip into Java code if you need to and embed the jobs in other programs.

Unfortunately, it’s not so good when it comes to generating moderately complex XML files. By moderately complex, I mean lists of lists like this:
(more…)

Optimal JVM settings for STS/GGTS

I recently switched from Eclipse 3.6 to STS 2.7.1 (based on Eclipse 3.7). Ditching my old .project and workspace settings files along with the move has made for a smoother experience; it seems these files get corrupted over time,1 and I’m too lazy to do the research to fix them. However, the upgrade resulted in performance issues. For instance, it hung for ~10 seconds every time I saved web.xml, and there were various random pauses. It’s not the hardware: I’m on a Core i7 Quad with 6GB RAM running Win7 x64. I realize you are getting more tooling with STS, but performance was much worse than I experienced with 3.6.

Well, it had slipped my mind that I had updated my 3.6 eclipse.ini settings with those I had found in an excellent Stack Overflow answer from VonC on optimal JVM settings for Eclipse. It hasn’t been updated for 3.7 (nor does it mention STS), but after some experimenting and research it appears to work well for it. Here are my settings, and below I add some commentary on what they do, which is missing from the original answer (although I still suggest you read that, as it covers other situations/issues that may affect you). Keep in mind I’m not a JVM tuning expert, YMMV, etc. Here are the contents of my sts.ini:

-vm
C:/Java/SDKs/jdk1.6.0_24x64/bin/javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
com.springsource.sts.ide
–launcher.defaultAction
openFile
–launcher.XXMaxPermSize
384M
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xmn128m
-Xms256m
-Xmx768m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=384m
-XX:CompileThreshold=1000
-XX:+CMSIncrementalPacing
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:+UseFastAccessorMethods

-XX:CompileThreshold=1000
This is the number of method invocations/branches before compiling. This is normally set to 10,000, so we’re changing it dramatically, but the original suggestion was leading to errors so I raised it. You will notice on startup that it takes longer, and your CPU usage jumps. However, your performance after that is much better. Those 10s save times for web.xml? Gone after this. I’m willing to take a hit at the beginning for better productivity while coding.

-XX:ReservedCodeCacheSize=64m
Related to the above, I was getting the error “Unhandled event loop exception / out of space in CodeCache for adapters” due to setting the compile threshold to 5. This is another solution to that problem, and may be redundant.

-Xss4m
This is stack size, and was previously set to 1MB, now up to 4MB per thread. Doing this will increase the overall memory used.

-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:+UseFastAccessorMethods

These enable parallel garbage collection. I saw my CPU utilization reach 100% after this, which is rare on a Core i7 Quad. It felt like I was finally using it to its potential.

Again, I’m not an expert. I’ve found it’s more sluggish at first, but response times quickly improve. For me, it’s a clear net gain. Not documented are the things I turned off in preferences because I wasn’t using them (Maven is disconnected, etc.). Visit Windows >> Preferences and filter on startup, see if there’s anything you can get rid of. Finally, I must give credit to my sources outside the original article:

http://ugosan.org/speeding-up-eclipse-a-bit-with-unlockexperimentalvmoptions/

http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

http://performance.netbeans.org/howto/jvmswitches/

  1. I’ve had issues with things like web deployment assemblies, not prompting for workspace on startup, etc. []

CC3260MT.DLL Is TiVo

I was trying to launch a Tomcat instance in Eclipse and it complained that port 8080 was in use. This scared me, since to my knowledge nothing else used that port. Was it spyware? I visited http://localhost:8080 and saw:

Access violation at address 32658D8F in module 'CC3260MT.DLL'. Read of address 00000000

No, it’s not spyware, it’s TiVo. Specifically the TiVo desktop server (Bonjour, I believe it’s called.). Pulling up the interface and pausing the server frees up the port. Shame on TiVo for using a very popular port for developers, but I guess we can change the port in Eclipse/Tomcat/Jetty if we need to. Now back to work…

Revert A File with WinCVS

For some reason, searching for “wincvs revert” in Google doesn’t immediately show http://cvsgui.sourceforge.net/newfaq.htm#reversion, which it absolutely should. It explains what you have to do, but to make it extra clear here is a screen grab:

You can replace HEAD with another version like 1.12.

BTW, if you’re on Windows and using Eclipse, WinCVS is a great support tool for Eclipse’s broken CVS support.1 I can get history/logs for files and revert to previous versions. Eclipse remote history has been broken for me through several upgrades/reinstalls and will only revert to a tag, not a specified file version.2

The only real issue I have with WinCVS is that its help system doesn’t provide any. Expect things like “Merge options dialog allows the user to change the merge options.” Still, I’m grateful for the effort and can’t complain about the price.

  1. It uses CVSNT so it’s compatible with Eclipse’s working directories; using Cygwin’s CVS can cause problems as it’s not really compatible with CVSNT. []
  2. I assume that would work if remote history worked, though. []