Archive for the ‘Java’ Category

Mobile Development

August 17th, 2007

Several months ago I purchased a new cell phone because I decided to join the cool people and jump on the media/internet/do it all phone bandwagon. With this in mind I purchased the Helio Ocean. Almost $300 cheaper than the iPhone this puppy has most of the best features found on a cell phone to date, with a service plan that is fairly priced.

Of course the developer in me saw that this phone uses Java technology for its applications. Hey, I know Java! I should write an application. The problem was that I had no real application need at the time so I shrugged it off.

Until now. Just two weeks ago I joined the Weight Watchers program in an attempt to lose weight. In case you aren’t aware, Weight Watchers uses a point system which is based off calorie, fat, and fiber content. Perfect! I need a little application on my phone to enter in calories, fat, and fiber and it spit out the points count.

Turns out that the mobile development part wasn’t so difficult. The hard part is getting your Java application TO your Helio and getting it to EXECUTE. The folks at Helio apparently do not wish third party people developing applications without their blessing so they require you to purchase a developer license from them. No thanks.

A little looking around on the internet turns up a few peeps who have figured out that Helio simply renames their JAR files, and adds two signatures to it. This coupled with a descriptor file allows you to download your custom application to your Helio device and execute it. So as a result I have made my first draft of the Weight Watchers points calculator application. It is VERY rough right now, and needs a bit of work. It is also not 100% accurate in the calculation, but it is pretty close, so it will work as a means to calculate points in a hurry or on the go. Meanwhile I will continue spicing the app up and once done will post on my website for consumption by not only Helio users, but also anyone who has a Java enabled phone.

Weight Watchers Application in Action

Tags: , ,
Posted in Development, Java | Comments (0)

Foray into Java

February 28th, 2007

So recently I’ve decided to delve into the world of Java development, or, more specifically, desktop Java development. So far I am liking it. My first task was to write a small application that would accept two dates as input and spit out a tab-separated report of first and last journal entries in a system, broken down by each day. Turned out to be a good learning experience, and useful to my bosses. :)

So if you’ve ever wanted to know how to connect to and use a Microsoft SQL Server 2000 box in Java, perhaps you will find this useful. First thing to do? Download the Microsoft JDBC Type 4 driver here. You don’t need the setup program, just the JAR files. So extract those to a location you can remember.

Now for my development I am using NetBeans 5.5. I highly recommend this product. Not only does it ROCK, but it is FREE! To get SQL 2000 working in your Java app you will need to add the SQL 2000 JAR files into your project classpath settings in NetBeans. Once you have done this, here is how you can connect to and read records from a table in Microsoft SQL Server 2000.

  1. DriverManager.registerDriver(new SQLServerDriver());
  2. Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databaseName=MyDb", "userName", "password");
  3.  
  4. PreparedStatement qry = connection.prepareStatement("SELECT * FROM myTable");
  5. ResultSet table = qry.executeQuery();
  6.  
  7. while (table.next())
  8. {
  9. someValue1 = table.getString("someColumn1");
  10. someValue2 = table.getDate("someColumn2");
  11. }
  12.  
  13. table.close();
  14. qry.close();
  15. connection.close();

Obviously you will need to import the correct packages and such, but you get the idea.

Tags: , ,
Posted in Development, Java | Comments (1)