Archives de l’auteur : Nicolas Riousset

À propos Nicolas Riousset

Président et fondateur de NeoLegal, développe des solutions logicielles qui facilitent le quotidien des professionnels du droit des sociétés.

Where are JAVA user preferences saved on Windows ?

If you want to store user preferences/settings for a JAVA application, the java.util.prefs.Preferences class is the way to go. It abstracts the storage of the user info, as explained in the JAVA doc:

This class allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store.

Question : On Windows, where are the JAVA user preferences stored ?
Answer : In the registry. Typically in HKEY_CURRENT_USER\Software\JavaSoft\Prefs\[your path] If you want to change your storage (i.e : backing store) you will need a new PreferencesFactory, as detailed in this post.

How to kill all active connections to a SQL Server DB before a restore ?

You may have faced situations when you need to restore a SQL Server database, but the restoration fails because a connected user prevents SQL Server from acquiring the required exclusive mode.

The T-SQL script below will kill all active sessions by switching immediately to exclusive mode. you’ll then be able to restore the db (or perform any other operation requiring exclusive mode), before switching back to multi-user mode. Continuer la lecture

How to resize the width of a JComboBox dropdown list without resizing its edit box ?

You need a JComboBox whose width doesn’t depend on the widest of its items, but you still want the dropdown list to be wider than the JComboBox, wide enough to display properly the widest item. For example :

wider combo box

Continuer la lecture

Questions to ask before a code refactoring

« Refactoring is the process of taking a running program and adding to its value, not by changing its behavior but by giving it more of these qualities that enable us to continue developing at speed. » – Kent Beck

A new developer gets his hands on an existing source code, and soon your hear this complaint : « Code is a mess, it must be refactored ! » Sometimes, that’s true, and some other times, that’s a great recipe to end up with a code as bad as – or even worse than – the initial code. To decide if a refactoring is required, here are ten questions you should ask yourself (or the developer asking for the refactoring): Continuer la lecture