Category Archives: MySQL

Thoughts on Oracle/Sun

Interesting quote about the Oracle/Sun acquisition from EETimes.com:

“Acquisitions have strengthened Sun’s position in the enterprise storage and business integration software markets, but have not positively affected the company’s business or financial profile.”

To put that another way: Sun has been attempting to achieve incremental successes at a game that nobody else really wants to play anymore. (I really liked another quote from this piece: Sun blamed “inconsistent profitability” for their downfall. I love “inconsistent profitability” as a euphemism for “losing money”; I hope I never have to use it with a straight face, but I’m prepared to if necessary.)

Some more thoughts on this:

1) Everybody’s touting the fact that “Oracle gets MySQL” in this deal. Sure, OK, there is the MySQL technology and the MySQL commercial licensing and support business. MySQL is generating revenue, but not the kind of revenue that’s interesting to a company the size of Oracle. My prediction is that Oracle’s sales force will do something dumb like treat MySQL as an entry-level product in hopes of upselling customers to the real (expensive) Oracle product, which won’t work because the kinds of organizations that want MySQL aren’t the kinds of organizations that want Oracle.

2) Ultimately the open source thing inoculates the MySQL product from a lot of potential corporate evil, which is one of the points of the open-source exercise in the first place. Open source means that if things get too onerous, the community can more or less take its ball and go home if it wants. And this is already happening; MySQL is already being forked (by independent companies like Percona as well as internally within Sun via the Drizzle project). Percona is usable in production today, but Drizzle is not (because that project got started more recently and is aiming at a more ambitious gutting and rearchitecture of the MySQL code base rather than incremental patches and improvements). Still, it is fair to say that if you are looking for the most advanced/optimized MySQL distribution today, you won’t get it from Sun, and I wouldn’t expect that to change under the Oracle regime.

3) A bigger meta-problem: Oracle has always had a serious problem with developer community relations and developer usability of their products. If they were to invest in one area to make this acquisition go more smoothly, it would be this — there are enormous bang-for-the-buck opportunities for them here. (I say this because of Oracle’s historical track record with managing its developer platforms as well as the visceral fear and outright revulsion I’m hearing today from developers after we got wind of this news.) It might have been possible for Oracle to mine the MySQL community for help here if this deal had materialized a year ago, but it seems like a lot of the principal MySQL community folks have either moved on from Sun or gone over to projects like Drizzle.

4) I do think the acquisition makes sense on some levels. There may be a good synergy with Oracle and Java, although Java was never an interesting business from a dollars and cents perspective and I don’t expect Oracle’s stewardship of the language to change things that much.

5) Many more junior- and mid-level salespeople in Silicon Valley are going to be without jobs in six months.

6) No clue what Oracle’s going to do with Sun’s hardware business, but it doesn’t really seem synergistic (and it screws up some of Oracle’s flagship partnerships with companies like Dell and HP). My guess is that they’ll shift it into some kind of maintenance mode.

7) Meanwhile, I am wondering whether HP shouldn’t pursue its own MySQL acquisition. I don’t know if there’s a “there there” in a potential HP acquisition of (for example) Percona, but if Oracle is going to compete with HP on hardware, HP should be prepared to compete with Oracle on databases and applications.

8) It’s interesting that an acquisition of this magnitude can take place without so much of a mention for what it might mean for Microsoft. I think that this can be looked at as a barometer of Microsoft’s relevance for enterprise computing.

Update: In his post on this, Matt says “I would not be surprised if this moment is for Drizzle what Movable Type changing their licensing was for WordPress, even though in this case they’re both Open Source.”

Sun/MySQL and .NET

Woke up this morning to the Sun/MySQL news; my initial thought was "uh oh". My big concern is whether Sun will continue to support languages-that-are-not-Java as well as MySQL has been doing.

But my concerns were at least partially laid to rest when MySQL’s CEO Marten Mickos explicitly called out their support for lots of different languages (including C#) and said they’ll continue to do so in the future. That’s good to hear, although as soon as the ink dries on the acquisition, it won’t be solely up to Marten to determine how much support Sun provides for a competing technology stack that Scott McNealy once referred to as "a joke". In fairness, that 2003 quote did more to reveal McNealy’s own ignorance regarding his competitors’ products than anything else, and of course he’s no longer calling the shots at Sun on a day-to-day basis. But still.

This is a concern for everyone because MySQL comprises the foundations of the technology stacks of so many companies, including Approver.com (which uses .NET and MySQL). It’s also a key component in the stacks of many of Platform Associates clients including Alfresco and others. On his blog, Alfresco’s CTO John Newton is raving about the opportunities the deal will provide. If he’s happy, then I’m happy.

Database Queries with Windows Powershell

I haven’t done a serious learning project for a while so this week I decided to play around with Windows Server 2008 and PowerShell. I’ll post some thoughts about Server 2008 soon (at first glance it looks terrific once you get past the fact that IIS is now a "role" instead of something you install). But I wanted to post a PowerShell example first because I wanted to do something with it that I couldn’t find information about anywhere — specifically, perform a database query and dump the contents to the console. (Later we’ll get fancy and dump it to HTML or send it somewhere via email, etc.)

PowerShell can invoke any .NET object, so I knew it was possible to do database stuff with a PowerShell script, but I couldn’t find any examples anywhere, so here’s what I cooked up via trial and error.

The first step is to create a database connection:


[system.reflection.assembly]::LoadWithPartialName("MySql.Data")
$cn = New-Object -TypeName MySql.Data.MySqlClient.MySqlConnection

The syntax to load a .NET assembly in PowerShell is pretty awkward; couldn’t they have provided a Get-Assembly cmdlet? (I suspect that thousands of PowerShell users have already written that one already.) Also, you have to know the assembly name of your ADO.NET provider (which, for MySql, is "MySql.Data," not "MySql.Data.MySqlClient," which was my first guess). The thing to remember is that loading an assembly is syntactically different than including a namespace even though the objective is sort of the same.

Fortunately this is the only part of the process that I didn’t get right the first time, and I had it resolved after a few minutes of experimentation.

I should mention that I’m using the MySql data provider because we use MySql on Approver.com, but you can obviously use any ADO.NET provider you want here. This assumes that your ADO.NET provider is installed in the GAC; if you need to make an explicit reference to an assembly in the file system the syntax is different.

Next, open the database connection:

$cn.ConnectionString = "SERVER=localhost;DATABASE=mydb;UID=xxx;PWD=yyy"
$cn.Open()

If you want, you can check the value of $cn.State here to make sure it worked. Then execute the query:

$cm = New-Object -TypeName MySql.Data.MySqlClient.MySqlCommand
$sql = "SELECT ID, FirstName, LastName FROM Person LIMIT 50"
$cm.Connection = $cn
$cm.CommandText = $sql
$dr = $cm.ExecuteReader()

ADO.NET programmers know that there are lots of ways to do this that require fewer lines of code, but I like to assign everything out explicitly using properties of the ADO.NET Connection and Command objects.

Finally we iterate over the results and close the connection:

while ($dr.Read())
{
    write-host $dr.GetInt32(0) " " $dr.GetString(1) " " $dr.GetString(2)
}
$cn.Close()

This is not too different than what a C# developer is accustomed to, particularly reading out the data. I like that you can just pass a big list of values to write-host without having to explicitly concatenate or convert to strings here. PowerShell figures out what you want to do and does the right thing.

On Approver.com we have a bunch of utilities that we use to monitor system health and site activity (like how many people registered that day, whether people are discovering and using certain features of the site, etc.). Every web site should crunch these numbers frequently (otherwise you have no idea whether the work you’re doing matters to your users).

I think I’m going to eventually migrate our various statistical and maintenance utilities to Powershell. The power of the .NET framework combined with the convenience of script is going to come in handy for a lot of stuff.

Cgen: Simplest .NET/MySQL Relational Wrapper That Could Possibly Work

Last week I attended and spoke at the MySQL conference. Some of the talks, particularly the ones that targeted system administrators rather than developers were over my head, but that’s useful information in itself — it serves as a reminder that sometime soon I’ll need to either learn the finer points of big-time MySQL system administrator or hire somebody who does.

It was particularly fun giving a talk on .NET to MySQL guys just two weeks after I finished giving a talk on MySQL to a room full of .NET guys. It was also fun seeing my client Alfresco and hanging out with them in their booth, where they were doing demos and fielding lots of inquiries.

I’m just now getting around to firing up the blog-o-matic in earnest after four weeks of more or less non-stop conference-going, but I wanted to mention that I’ve released the tool that we use to create the data access layer. It’s called Cgen, and it lives here.

The idea behind Cgen is that you create an XML document that represents your database schema, and Cgen (which is packaged as a command-line tool written in C#) spits out a bunch of classes that make it easy to do the basic create, read, update, and delete operations that represent 80% of all database-driven applications. (For the remaining 20% of the data access code you’d need to write, the tool generates subclasses that you can add your own code to.) You can then compile these classes as a .DLL or, if you’re making an ASP.NET 2.0 web application you can just dump the classes into the application’s App_Code folder and .NET will figure out how to compile the classes.

We use code generated by Cgen as our data access layer for Approver.com. It has worked splendidly and saves us a bunch of time. At the same time, Cgen doesn’t have a ton of bells and whistles. I realize that this is probably the one millionth object/relational code generator in the history of software development. I took a look at other object/relational mappers like SubSonic, and I used NHibernate on an intranet project I did at Yahoo in 2005. But for Approver I wanted a tool so simple that you didn’t spend more time learning the tool than you would have spent writing the code yourself. I also needed something with good support for .NET 2.0 and MySql (which was difficult to find in March 2006 when I started using MySQL).

At MySQL Conference This Week

I am spending today preparing for my session at the MySQL conference on Thursday. I’ll be speaking on "MySQL and .NET in the Real World" which will cover my experience creating Approver.com and will also include a run-through of the Visual Studio integration with MySQL.

Last year I created a little command-line tool that generates MySQL data access classes for .NET 2.0. It’s the tool that generates the data access layer for Approver.com. I am going to open-source this tool this week, most likely before my talk on Thursday, and I will do a demo of the tool as part of my talk at the conference. This tool is very simple — it doesn’t do as much as, say, SubSonic or NHibernate. But it does automatically generate about 80-90% of the data access code used in Approver.com, and it has a few ease-of-use characteristics that I wanted — mainly a low learning curve, explicit support for MySQL and .NET 2.0 and no dependencies on external libraries other than what you find in the framework.

I need to do an intro/documentation page that describes the tool. I’ll get to that in the next day or two, then I’ll post here when it’s available.

New Version of MySQL .NET Connector

A while back I posted that the 5.x line of MySQL connectors was a bit too garden-fresh for production use. Fortunately Reggie and team have quickly released a new version: here are the details.

From the release notes it looks like they might have resolved the problem that I was having. I’m still using the 1.0.9 connector for now but I’ll be testing the new 5.0.5 version as soon as I get some time in hopes that I can show off MySQL/Visual Studio integration at VSLive in a few weeks.

Update: Reggie says that 5.0.5 isn’t soup yet, either: details here.

MySQL .NET Connector Madness

As I’ve been writing about here for a while, my big learning project of 2006 was to pick up MySQL and to build a web site using ASP.NET with MySQL as the back-end. This went really well, better than I could have expected. For someone who has experience with SQL Server, the learning curve isn’t too bad, and MySQL clearly did a lot of things with developer productivity in mind.

One of the things that I try to do when I write articles or do talks on technologies is to use the latest versions of everything, so when I started preparing my upcoming VSLive talk, I upgraded everything on my dev boxes, including the server, the ADO.NET providers, etc.

MySQL provides two sets of "connectors" for .NET developers. (.NET developers know these as "ADO.NET providers".) The connectors in the 1.0 line are more stable, but they don’t support the new features of ADO.NET that came out in .NET 2.0, which means that stuff like declarative data sources as well as the MySQL Visual Studio add-in won’t work — all this stuff expects to see the 5.x connector installed in the global assembly cache.

Unfortunately, the 5.x line of connectors isn’t ready for prime time yet — some folks (including me) have had problems consistently connecting to the server with the latest 5.0.x connector. So yesterday I backed out the upgrade and I’m using the 1.0.9 connector for now. I should mention that this version of the connector is also live in production on Approver.com right now and it’s 100% solid.

To their credit, Reggie and the MySQL team do a great job of providing information and feedback when issues like this come up, as they inevitably do — I feel like I can get way more information from MySQL than I ever could from Microsoft or Oracle in situations like this. So I’ll hang in there, and if they can get another rev of the 5.x connector I’ll give that a whirl before my VSLive talk.

Update: They released a new version of the 5.x connector that may fix this problem.

Outline of My MySQL Talk at VSLive

Here’s a list of slides I’m developing for the MySQL talk I’m giving at VSLive next month. This talk is intended for developers who are proficient with .NET and some kind of relational database but with with little or no exposure to MySQL. I am pretty sure that the talk is going to be 60 minutes in duration, so 30-40 slides should be about right.

Did I leave anything important out? Let me know in comments — thanks!

  1. What is MySQL?
  2. Meta: About Open Source Software
  3. Obtaining MySQL
  4. Installing MySQL
  5. Configuration
  6. Jeffrey’s my.ini File
  7. Gotcha: Security Settings
  8. Command-Line Tools
  9. MySQL GUI Tools
  10. Visual Studio Integration
  11. MySQL Administrator
  12. MySQL Query Browser
  13. Creating a schema
  14. Pluggable Storage Engines
  15. Data Types
  16. Enumerations
  17. Gotcha: Set DATETIME Defaults
  18. Unicode Support
  19. MySQL Query Manager
  20. MySQL ODBC Driver ("it exists")
  21. MySQL ADO.NET Provider
  22. Creating a DataReader
  23. DataReader with Parameters
  24. DataSet
  25. Subselects
  26. Use LIMIT N instead of TOP N
  27. Stored Procedures
  28. Transactions
  29. Triggers
  30. Clustering
  31. Replication
  32. Architecting for Scalability
  33. References

Installing the MySQL ADO.NET Connector into the Global Assembly Cache

This morning I sat through a MySQL webinar on Visual Studio tools for MySQL presented by the most excellent Reggie Burnett.

One of the questions that came up after the talk pertained to installation problems on Windows. (I should preface all this by saying that MySQL, the database server, has a good installer and is a snap to get running on Windows.)

I don’t usually use MySQL’s pre-compiled installers on Windows — now that I sorta know what I’m doing, I find it’s usually faster to set up MySQL and its attendant GUI tools without installers. And MySQL supports the notion of downloadable zips without binary installer cruft, which I really like, particularly in situations where you just need to yank one file out of the distribution (like documentation) without having to go through a whole big install.

But for those of us who eschew installers, there’s a trick with the MySQL tools for Visual Studio: the installer for the Visual Studio add-in apparently expects to find the MySQL ADO.NET provider (which MySQL refers to as "Connector/Net") in the Global Assembly Cache. If it doesn’t find the provider in the GAC, the add-in won’t run.

I was dimly aware of the existence of the GAC but I’d never needed to do anything with it myself in the real world (aside from mentioning it in my books). This isn’t a huge inconvenience, though. First you just need to locate a command-line utility called gacutil.exe on your machine (mine’s in the SDK directory under Visual Studio 8, but yours might be somewhere different depending on what tools you’re using).

Next you’ll need to locate MySql.Data.dll on your machine. This file can be located anywhere if you’re difficult like me and you don’t use an installer.

So, the entire command line I needed to use to install the MySQL provider in the GAC was:

"C:Program FilesMicrosoft Visual Studio 8SDKv2.0Bingacutil.exe" /i "C:Program FilesMySQLConnector.NET 5.0.3Driverbinnet-2.0releaseMySql.Data.dll"

(The /i switch means "install".)

This is certainly not brain surgery but hopefully putting all this in writing will save others some time.

A MySQL IPO in 2007?

Link: GigaOM » MySQL prepping for an IPO.

"Long a favorite of web developers, MySQL saw serious growth in 2006 and added 2,500 new customers, and also introduced MySQL Enterprise. There seems to be a renewed interest in open source IPOs….For starters, the corporations have taken a shine to the open source3 software.

Secondly, most companies with IPO dreams have been around for a while and have been able to build solid businesses around their offerings."

This is very good news for our friends from Uppsala and for open source businesses in general. For years the database market has been ripe for disruption and now it seems like MySQL is approaching a serious tipping point. I’ll be watching this closely.