Posts

Java Dates: java.util.Date, java.sql.Date, java.util.Calendar

Working with dates in Java (though not limited to Java) has always been a nightmare. There are lots of good articles out there in Google Land on the topic, but after some very good questions from my class, I thought I'd add my two-cents and code samples to the mix. Much of the confusion centered around conversion, so here's some basic how-to snippits: Convert java.util.Calendar to java.util.Date: java.util.Calendar calendar = java.util.Calendar.getInstance(); java.util.Date utilDate = calendar.getTime(); //or by using the constructor java.util.Date utilDate = new java.util.Date(calendar.getTimeInMillis()); Convert java.util.Date to java.sql.Date: java.util.Date utilDate = java.util.Calendar.getInstance().getTime(); java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); Convert java.util.Calendar to java.sql.Date: java.util.Calendar calendar = java.util.Calendar.getInstance(); java.sql.Date utilDate = new java.sql.Date(calendar.getTimeInMillis()); Here we have to create...

WCF InstanceContextMode and ConcurrencyMode

I recently ran into a concurrency issue with WCF on a customer's system. I'll get into the details later (though not too much detail... NDA ;) ), but it involved some testing of the various combinations of InstanceContextMode and ConcurrencyMode settings for a WCF service. The table below is an attempt to clarify the results... InstanceContextMode ConcurrencyMode Resulting Behaviour PerCall Single New InstanceContext created per call Calls processed concurrently, because each call gets it's own instance Multiple Same as with ConcurrencyMode.Single PerSession Single New InstanceContext is created for each client proxy connection Each call is pooled and processed serially in a FIFO manner Multiple New InstanceContext is created for each client proxy connection Each call is processed as soon as it arrives A single instance of the proxy is required for concurrent processing from a single client Singlton Single Single instance of an InstanceContext Each call is pooled and proc...

Using Multiple Active Result Sets (MARS) in SQL Server

A lot of ground was covered in connecting our TellerUI to the database. We implemented FinderMethods in our Customer class that return an IList back to the UI to be bound to the results grid. We also implemented an App.config file to store our connection string. While we did get the code working, it was not as expected. We originally implemented it to use the same connection for all operations throughout the find and load process, so we we're not opening and closing connections over and over; a very costly operation. However, this caused a runtime error. The connection would not allow multiple data readers to be open at a time. Our stop gap solution to get the app working was to simple use a new connection for every call to the database. I spent some time debugging the original design. The solution was a setting in the connection string-- MultipleActiveResultSets=True --which allows us to have multiple resultsets open at a time in SQL Server 2005 and 2008. The new connectio...

Installing TimeTTracker MX2 on a Smartphone

Image
ISSUE: Installing TimeTTracker MX2 on a UT Starcom X5800 smartphone Operating systems: Windows Vista Business 64-bit Windows Mobile 6.0 Here's some background... I've been using TimeTTracker MX2 by R&F Consulting, Inc. ( http://www.rfcons.com ) for quite some time now, and love it. If you're a consultant, you have to take a look at their product. If you are in a profession that requires you keep accurate record of your time and expenses, especially while on the go, then you also know the pain when such a tool suddenly stops working. I'm using Windows Vista Business 64-bit on my laptop, and at one point had upgraded to WMDC 6.1. My last mobile device was the UT Starcom XV6700 (Verizon Wireless version) running Windows Mobile 5.0. TimeTTracker MX2 installed and sync'd flawlessly in this configuration. Having some performance issues with the XV6700 itself, and unhappy with it's bulky size, I downsized to the UT Starcom X5800 (Verizon Wireless SMT5800), runn...