Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
Java Database Connectivity – MySQL, Oracle and SQLite
I have played around with database connectivity with Java for MySQL, Oracle and SQLite. I thought I would share some simple connection setup code with the world.
You will need to download and add the appropriate JARs to your project and or your class path, as well as having a database to connect to, unless you are using SQLite in which case the database is local.
MySQL
First up is MySQL connectivity. This first snippet will check you have loaded the JDBC driver correctly.
import java.sql.*;
public class MySqlLoadDriver {
public static void main(String [] args) {
Connection con = null;
try {
// Load the MySQL JDBC driver
Class.forName("com.mysql.jdbc.Driver") ;
System.out.println("MySQL JDBC driver loaded ok.");
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
}
}
}
The following snippet will set up a connection to the database. Where the host in the example is set to localhost so you may change this to point to your database address or tunnel in to your database using a client like Putty. Also change username and password to your database username and password.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class SimpleConnection;
{
static public void main(String args[])
{
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver") ;
System.out.println("MySQL JDBC driver loaded ok.");
con = DriverManager.getConnection(
"jdbc:mysql://127.0.0.1:3306/","username", "password");
System.out.println("Connected with host:port/database.");
con.close();
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
}
}
}
Oracle
Oracle has a two types of connection I have played with Oracle Call Interface and Oracle’s JDBC Thin driver uses Java sockets to connect directly to Oracle. It provides its own TCP/IP version of Oracle’s SQL*Net protocol. Because it is 100% Java, this driver is platform independent and can also run from a Web Browser. Depending on which one you want to use comment out or delete the other line. In the example I am using the OJDBC Thin Driver not the Oracle Call Interface.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class OracleSimpleConnection {
static public void main(String args[])
{
Connection con = null;
try
{
Class.forName ("oracle.jdbc.OracleDriver");
System.out.println("Oracle JDBC driver loaded ok.");
con = DriverManager.getConnection(
//"jdbc:oracle:oci7:@//localhost:1521/ORCL","username", "password");
"jdbc:oracle:thin:@//192.168.104.11:1521/ORCL","username", "password");
System.out.println("Success!!");
System.out.println("Connected with host:port/database.");
con.close();
}
catch (Exception e)
{
System.err.println("Exception: "+e.getMessage());
}
}
}
SQLite
Finally the creation and testing of an SQLite Database, adding in a few things with a simple query.
import java.sql.*;
public class SQLiteTest {
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists people;");
stat.executeUpdate("create table people (name, occupation);");
PreparedStatement prep = conn.prepareStatement("insert into people values (?, ?);");
prep.setString(1, "Gandhi");
prep.setString(2, "politics");
prep.addBatch();
prep.setString(1, "Turing");
prep.setString(2, "computers");
prep.addBatch();
prep.setString(1, "Wittgenstein");
prep.setString(2, "smartypants");
prep.addBatch();
conn.setAutoCommit(false);
prep.executeBatch();
conn.setAutoCommit(true);
ResultSet rs = stat.executeQuery("select * from people;");
while (rs.next()) {
System.out.println("name = " + rs.getString("name"));
System.out.println("job = " + rs.getString("occupation"));
}
rs.close();
conn.close();
}
}
Useful Links;
http://www.zentus.com/sqlitejdbc/
How to install the Oracle JDBC into your local Maven repository
This will work to install any jar or package into your local Maven repository, just change the relevant sections in the command line entry.
To get the Oracle Driver go toand then to the JDBC Drivers page which at the time of writing is here:
Ensure you have Maven properly setup on your machine.
Navigate to the folder containing the jar in a command line prompt.
Enter the following;
mvn install:install-file -Dfile=ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.3 -Dpackaging=jar -DgeneratePom=true
Where:
-Dfile is the path to file
-DgroupId is the group ID
-DartifactId is the artefact ID
-Dversion is the version of the package
-Dpackaging is the package type i.e. jar
- DgeneratePom will automatically generate the pom.xml entry
Note: If you are using Powershell you will need to escape the – with a back tick so -Dfile=ojdbc5.jar becomes `-Dfile=ojdbc5.jar`
If you are adding Sun JARs is there is a helpful article on naming conventions to use here.
Useful links;
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
http://stackoverflow.com/questions/442230/how-to-manually-install-an-artifact-in-maven-2
http://stackoverflow.com/questions/1074869/find-jdbc-driver-in-maven-repository
Locked Out of Your Android Phone
Android – Locked Out
Ok, so for whatever reason you have entered your little pattern too many times on your Android phone and you are now locked out. You can’t remember your pattern, something or someone else entered it too many times or something of the like and you are now stuck at the “Too Many Pattern Attempts” screen. The phone is demanding the Google account details that you synced the phone with when you very first turned it on. Maybe you have now forgotten those login details too or the phone is simply refusing to accept the correct login details.
For whatever reason you are at a dead end and stuck at the too many pattern attempts page of doom, however, all is not lost. Far from it my dear reader! If you simply want to get rid of the pattern lock you which you are stuck trying to remember, but aren’t yet completely locked out, you are in luck.
Firstly note that;
- Removing your battery and SIM or just the battery will NOT solve your problems
- A hard reset will solve your problems; however, it will erase ALL personal data from your device. You will be able to download your applications from the store again, and sync all of your contacts again from Google but all texts and personal data that is not synced or backed up externally, say on to your memory car, WILL be lost.
- Using Android Debug Bridge (adb) will only disable the pattern lock if you are not already locked out completely and at the too many pattern attempts page of doom.
So What Can You Do?
- Enter your email address in to the device
- In the password field enter “null” without the speech marks.
- You will then be prompted to enter a new pattern and once again you have your phone back in action with all data intact.
That Didn’t Work, What Now?
- There are reports that if you have uppercase letters in your email address and or password that trying again with them in lower case will work.
- If you have got USB Debugging already enabled on your device, and you are not quite at too many pattern attempts page of doom then you can disable the pattern lock via adb.
How to Disable Pattern Lock via ADB
- You must have previously enable USB Debugging (Settings -> Application -> Development -> USB Debugging)
- Download and extract the Android SDK (from here)
- Plug your phone into your computer
- In command line navigate to where you extracted the SDK, then to the Tools folder which should contain adb.exe
Do not simply run adb.exe but instead enter adb –d shell. Your command prompt should look like the following;
- Now disconnect and power off your phone, and turn it back on and the pattern lock should be gone.
What If I Didn’t Have USB Debugging Enabled?
I hate to say it but you are more or less at the end of the road.
A factory reset is probably your only option.
How to Factory Reset
HTC Dream
1. Turn the G1 off. If it’s frozen on, take the battery out and put it back in the unit.
2. Hold the Home and Power keys down at same time for about 25 seconds. You will see a yellow triangle screen with exclamation point in the
middle.
Now to wipe the device clean:
3. Press Alt+L.
4. Press Alt+W for a factory reset.
5. Press the Home and Back keys again for about 25 seconds.
The device should then reset again and the hard reset is complete.
HTC Magic
1. With the phone turned off, press and hold the HOME and BACK
2. Briefly press the END CALL/POWER button while continuing to press HOME and BACK buttons.
3. When you see the screen with the 3 Android images, release the HOME and BACK buttons, and then press the TRACKBALL.
Tip : If your phone hangs or freezes, remove the battery then wait for a few seconds, and then re-install it. After re-installing the battery, turn on the phone.
HTC Hero
1. With the phone turned off, press and hold the HOME and BACK and then briefly press the END CALL/POWER button. The reset process will start after a few seconds.
2. Wait for the phone to finish the reset process and then press MENU.
Tip: If your phone hangs or freezes, remove the battery then wait for a few seconds, and then re-install it. After re-installing the battery, turn on the phone.
HTC Tattoo
1. With the phone turned off, press and hold the HOME and BACK and then briefly press the END CALL/POWER button.
2. Press the ENTER button to begin the reset process.
Tip: If your phone hangs or freezes, remove the battery then wait for a few seconds, and then re-install it. After re-installing the battery, turn on the phone.
Motorola Droid
To reset your phone to factory settings and erase all the data on your phone,
Touch Menu > Settings
> Privacy > Factory data reset > Reset phone.
Warning: All data on your phone will be deleted.
Motorola Droid Hard reset with keys
Power off device.
Press X key on hard keyboard + power button, then release both buttons.
When you see exclamation point press and hold VOLUME UP + CAMERA KEY. You will see Android system recovery menu.
With D pad go to data / factory reset, then press CENTER D Pad, then choose Yes.
Nexus One
1. With the phone off, hold the Volume Down button and press and release the Power button.
2. You’ll boot into the menu you see above with the little skateboard guys. Select Clear Storage from the list by pressing the Volume Down button.
3. Press the Power button, and confirm by pressing Volume Up.
4. Sit back while your phone reboots in its virgin state.
LG GW620 [Eve] Hard Reset
To do a hard reset or data reset in LG GW620 aka EVE
Enter using Dial pad
3845#*620#
From menu select factory reset or whatever you want.
Motorola Dext
Factory Reset:
1. Holding the Camera button while turning on your phone,
2. When prompted hit the Volume-Down rocker button to go into Recovery Mode.
3. After you get into Recovery Mode,
4. Press ALT+L to reset, then Menu + Back to reboot.
HTC Droid Eris Hard Reset
Perform a hard reset on your HTC Droid Eris. These steps will clear all data and settings off the device.
1. With the phone turned off, press and hold the Volume Down and Send buttons.
2. Press the Power button.
3. Follow the instructions to complete the hard reset.
LG GW620
Hold down the volume down, menu and camera buttons for about 5-10 seconds and a message will appear asking you to confirm the factory reset.
HTC Desire
1. Turn your phone off
2. Hold the volume button down, whilst doing so press and release the power button
3. You should now see a menu that offers Fastboot, Recovery, Clear Storage and Simlock
5. Select clear storage by pressing the volume down button
6.Press the power button again
7. Confirm this by pressing volume up for yes or down for no
Samsung GT-i900 Galaxy S
Try holding the volume up and the home button, or volume up and down buttons
Whilst doing so press the power button for 2-3 seconds, release but maintain the press on the volume button
Now use the volume down button to select Wipe Data and press power button to confirm. Use the volume button again to select the final confirmation.
Useful Links
http://developer.android.com/guide/developing/tools/adb.html
http://www.backuphowto.info/how-backup-android-and-htc-hero-phone
http://code.google.com/p/proxoid/wiki/installationPhone
http://www.gsm4bd.com/showthread.php?21585-Android-Phones-Hard-Reset&p=33586
Upgrade your Asus Eee to Windows 7
This is a brief guide as to how to install Windows 7 on your Asus Eee netbook.
Firstly go to http://support.asus.com/download/download.aspx?SLanguage=en-us
Search for Eee Family, Eee PC, 1005HA and download the following to an external media such as a USB stick.
- BIOS (v.1102 or above)
- Chipset Intel 945 (v9.1.1.1016)
- VGA Intel (v8.15.10.1867)
- SATA AHCI (v8.9.0.1023)
- Touchpad (v13.2.6.1)
- Bluetooth (v6.2.0.9600)
- KB Filter (v1.0.0.3_32)
- Audio (v6.0.1.5898)
- LAN (v1.0.0.23)
- Wireless 785H (v8.0.0.238 or above)
- HotkeyService (v1.11.01)
- Super Hybrid Engine (SHE) (v2.09)
- ASUS Update (v1.03.03)
Then..
- Under Windows XP in your Eee PC, upgrade BIOS via the ASUS Update.
- Install Windows 7 operating system from the DVD. Ensure that it is in the same language as your current Windows® XP operating system.
- Install required drivers, utilties, and applications in the following order:
I. Chipset Intel 945: Run “Setup.exe”
II. SATA AHCI:
Select “Start” then;
- Select “Computer” and click the right mouse button
- Open “Manage”
- Select “Device Manager” under “System Tools” in the left hand column
- Open “IDE ATA/ATAPI controllers” in the right column
- Open the item with “AHCI”
- Select the “Driver” page
- Enter “Update Driver…”
- Use “Browse…” to locate the “SATA AHCI_v8.9.1023” folder or where you saved the downloaded AHCI driver.
III. VGA Intel: Run “Setup.exe”
IV. Hotkey Service: Run “HotkeyService_1.11.01.exe”
V. Touchpad: Run “Setup.exe”
VI. Bluetooth: Run “Setup.exe”
VII. KB Filter: Run “PNPINST.exe”
VIII. Audio: Run “Setup.exe”
IX. LAN: Run “Setup.exe”
X. Wireless 785H: Run “Setup.exe” in the “Install_CD” folder
XI. Super Hybrid Engine: Run “SuperHybridEngine_2.09.exe”
XII. ASUS Update: Run “AsusSetup.exe”
At this point you should be good to go!
For any assistance during the installation process, contact ASUS Support;
http://support.asus.com/contact/contact.aspx?SLanguage=en-us
Boots Opticians – Welcome

Welcome to Boots Opticians
Currently our twin practices in New Malden and Worcester Park.
For sight tests, contact lens assesments and after care please call one of our practices directly.
Boots New Malden, 82 High Street, New Malden, Surrey, KT3 4ET.
Boots Worcester Park, 118 Central Road, Worcester Park, Surrey, KT4 8HT.
Alternatively, email bootsopticians@easy.com and we will contact you
To contact New Malden Boots TEL: Appointments: 020 8942 0570
General: 020 8942 2112
Fax: 020 8942 3688
To contact Worcester Park Boots TEL: Appointments: 020 8330 7586
Fax: 020 8337 2093
For any enquiries with regards to this domain name please email admin@bootsopticians.co
Custom Colours for Checkboxes in User Forms Excel 2007
How to make a checkbox in Excel match the fill of a cell, background or text colour
This guide is using Excel 2007.
Select the cell which has the fill you require, then in the Home ribbon select the fill icon, and click on More Colors…
In the Colors dialogue select the Custom tab. Take a note of the RGB code for the fill of the cell. So in the screen shot the RGB is 255,204,153.
Now you need to convert the RGB value to Hexadecimal. I would recommend using http://www.endprod.com/colors/rgb2hex.htm but you can always Google for a different converter.
Now with your Hex value you need to format it ready for input into Excel. The simple explanation is that for Excel you need to build a String to enter as the BackColor property.
The String will start with &H00 followed the Hex you just generated. However, you need to swap the last two characters of the hex string with the last, so if your Hex code is ffcc99 then you need to use 99ccff. So, now you have your string &H00*****, where the asterisks are replaced with your Hex code add a final & to the string and you are now ready to go.
Return to Excel, in the Developer tab on the Ribbon (to add Click the Microsoft Office Button, and then click Excel Options. Click Popular, and then select the Show Developer tab in the Ribbon check box) click on the Design Mode icon. Now single click on the CheckBox you want to change the color of and then in the Properties box enter your new color string in the BackColor, or if it is for the text color enter the string into the ForeColor property.
About Me
I am Matthew Hollander BSc (Hons) Sofware Engineering, Durham University. My CV.




