Wednesday, February 15, 2012

Unholy union: Glassfish and MSSQL

I'm in a situation where the data is on a Microsoft SQL Server and I want to use Glassfish and J2EE. And all of this done inside Netbeans.
SQLServer + Netbeans?
Getting Netbean's version of Glassfish to work with MS SQLServer 2008 is a trick. When you start it up and open the Admin console webpage you'll head to the Resources > JDBC > JDBC Connection Pool and open make a new connection. You'll finish out the wizard until you try to ping the server. FAIL!

The problem is Netbean's version of Glassfish doesn't have the correct jars. Open C:\Program Files\glassfish-3.1.1\glassfish\lib; take a look and facepalm at this display of fail from Oracle.

Lets not dwell on that.

So we need a JDBC driver and a JDBC driver we shall get. Don't worry although its Microsoft, it won't cost you a thing. Documentation here. Driver here and just drop the jar file into that folder you just opened. Use the sqljdbc4.jar. Don't forget to restart the Glassfish server.

Now we redo the step in creating the JDBC connection pool resource. Here is what I did:
  1. Named the Pool: MSSQL2008
  2. Set the resource type to: java.sql.driver
  3. Set the driver class name to: com.microsoft.sqlserver.jdbc.SQLServerDriver
  4.  Set my properties to the following values:
    • URL = jdbc:sqlserver://{iptoserver};instanceName={name};databaseName={defaultdb};integratedSecurity=false;
    • user = my admin username
    • password = duh!
Troubleshoot if the ping test fails.

Don't forget to create a JDBC resource after you succeed in creating your connection pool in Glassfish. You'll need it if you want to get database access via JNDI.

Saturday, February 11, 2012

Adb can't detect my Android Phone. Damn.

So you open a command line and type in adb devices and, guess what, it can't detect your Android phone. This could be because of a variety of reasons like you installed a custom ROM. In any case, adb can't detect your device. Fortunately, the fix is just to install a driver. The bad part is the phone manufacturers sometimes don't post their USB drivers on the net.

How do we fix this?

1. Identify who really makes your phone. Like mine, which is sold as the Cherry Mobile Magnum HD but its actually a Foxconn phone. Do a google search or a lsusb command if your running a Linux box. You should be able then to get the ATTR{idVendor} value.

2. With that, go to this webpage. That should explain how to get your device recognized and help you figure out who made your phone.

3. You should be able to figure out which OEM driver to get.

Install and then you might have to do a reboot. When you get back, your Android phone now should be recognized by running adb devices again. You should be looking at something like below.
adb devices
This is related to my older post: Getting Ubuntu to play nice with your Android device.


Sunday, February 5, 2012

ICS for your Cherry Mobile Magnum

I'm trying out Alpha1 Alpha2  Alpha3 AOSP ICS Rom for Huawei x6 and other FB0 devices. The ROM is cooked by edowar. The ROM is currently Alpha, its working but its still a ways off.

Although, its still alpha it did install painlessly. The procedure is:


1. Downloaded new rom. (.zip) to your SD card
2. Go to 'backup and restore ' and take a backup
3. Reset userdata, cache and dalvik !important
4. Install the zip from SD card
5. Reboot system and you are done

After the install if you already rooted your Cherry Mobile Magnum, it stays rooted. After the reboot, you'll notice that it doesn't have any apps. So get GAPPS and install it following the same procedure for the ROM.

Unfortunately the ROM, doesn't have support for the camera and WIFI yet. Edowar and team are still working on it. And they as nice as the ICS rom is to look at, they don't have an ETA.

Despite of the shortcomings, my preview of the ICS rom has had me convinced that to wait for a release. From what I can see, the ROM is pretty stable (1 reboot for the week I had it) and is choke full of eye candy.

Can't wait!

Friday, February 3, 2012

.NET MVC3, Web Forms, Tapestry5 and Arnold being dead

They told me to learn .NET MVC3 or get fired and I'm like fine, whatever. I hack java, groovy, javascript, Less CSS and HTML5, how hard .NET MVC3 can be? I mean, Java has a ton of MVC frameworks (Struts, Play, etc.) and I've used (or at least tried) a lot of them. And don't get me started with PHP - CodeIgniter, Zend, etc.

Apparently, it isn't that hard, C# .NET is more or less a direct rip of Java with some syntactic sugar and good ideas. It took me about a week to find a groove with .NET MVC3 and another week to learn Entity Framework (which BTW, looks like Hibernate in Microsoft branding). So, I was chugging out good code and then Arnold told me to try out Web Forms. "It's like Tapestry5." He's words. He's. Last. Words. Then I BEAT HIM to DEATH with my old IBM ceramic keyboard.

Web Forms IS NOT Tapestry5!

Tapestry5 is way, waaaaaayyyyyyyy cleaner than Microsoft's Web forms. Proof? Try making a non-trivial Web Form's based web application and take a look at its "Code Behind" classes and generated HTML. I see spaghetti and it doesn't adhere to Tapestry5 programming tenets of  Single Responsiblity Classes and Seperation of Concerns.

What kind of class code are you writing when it balloons past 1k lines and you can't identity what it actually does from the first 20 or so lines?

Another that rubs me the wrong way with Web Forms  is that I have limited control on how to the HTML is generated. You can argue that I could "override" it, screw that, its more trouble than its worth.

And lastly, Web Forms is a bitch when trying to work in your favorite JavaScript library.

I though writing this blog would be, you know, cathartic. It's just making me angry again.

Where is that keyboard.....