@@ -0,0 +1,2960 @@
+package com.brewtab.ircbot.util;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0Aimport java.io.Serializable;%0Aimport java.sql.Blob;%0Aimport java.sql.Connection;%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0A%0Apublic class SQLProperties%3CV extends Serializable%3E %7B%0A    private Connection connection;%0A%0A    public SQLProperties(Connection connection) %7B%0A        this.connection = connection;%0A        try %7B%0A            this.connection.prepareStatement(%0A                %22CREATE TABLE IF NOT EXISTS properties (k VARCHAR PRIMARY KEY, v BLOB)%22%0A                ).execute();%0A%0A            this.connection.prepareStatement(%0A                %22CREATE INDEX IF NOT EXISTS idxprops ON properties(k)%22%0A                ).execute();%0A        %7D catch (SQLException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    public V get(String key) %7B%0A        try %7B%0A            PreparedStatement statement = connection.prepareStatement(%0A                %22SELECT v FROM properties WHERE k = ?%22%0A                );%0A%0A            statement.setString(1, key);%0A%0A            ResultSet results = statement.executeQuery();%0A            if (results.next()) %7B%0A                Blob valueBlob = results.getBlob(1);%0A                InputStream stream = valueBlob.getBinaryStream();%0A                ObjectInputStream objectStream = new ObjectInputStream(stream);%0A%0A                return (V) objectStream.readObject();%0A            %7D else %7B%0A                return null;%0A            %7D%0A        %7D catch (SQLException e) %7B%0A            throw new RuntimeException(e);%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D catch (ClassNotFoundException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    public void set(String key, V value) %7B%0A        try %7B%0A            Blob blob = connection.createBlob();%0A%0A            ObjectOutputStream valueStream = new ObjectOutputStream(blob.setBinaryStream(1));%0A            valueStream.writeObject(value);%0A            valueStream.close();%0A%0A            PreparedStatement statement = connection.prepareStatement(%0A                %22UPDATE properties SET v = ? WHERE k = ? LIMIT 1%22%0A                );%0A%0A            statement.setBlob(1, blob);%0A            statement.setString(2, key);%0A%0A            // If no update was performed instead insert the value%0A            if (statement.executeUpdate() == 0) %7B%0A                statement = connection.prepareStatement(%0A                    %22INSERT INTO properties (k, v) VALUES (?, ?)%22%0A                    );%0A%0A                statement.setString(1, key);%0A                statement.setBlob(2, blob);%0A                statement.execute();%0A            %7D%0A        %7D catch (SQLException e) %7B%0A            throw new RuntimeException(e);%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%7D%0A

Add SQLProperites class for storing simple key value properties