Hi guys I am grade 11 student. I have to create a offline social network. Now I am struggling to send a message, storing it to a access database and then the recipient must be able to retrieve the message. As well to search for a friend from names stored in the database
Here's is my database connection:


import java.io.*;
import java.sql.*;
import java.util.*;

public class WebConnection
{
Connection conn;

public WebConnection ()
{
connect ();
}

void connect ()
{
try
{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException c)
{
System.out.println ("Unable to load database driver");
}

try
{
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database += "db1.mdb;DriverID=22;READONLY=true}";
conn = DriverManager.getConnection (database, "", "");
}
catch (Exception e)
{
System.out.println ("Unable to connect to the database");
}
}


public String Register (String ID, String Password, String Age, String Gender, String DateOfBirth, String name, String Surname)
{
StringBuffer sb = new StringBuffer ();
try
{
Statement stmt = conn.createStatement ();
stmt.executeUpdate ("INSERT INTO User(ID, Password, Age, Gender, DateOfBirth, name, Surname )Values('" + ID + "','" + Password + "','" + Age + "','" + Gender + "', '" + DateOfBirth + "', '" + name + "', '" + Surname + "')");
stmt.close ();
}
catch (Exception e)
{
System.out.println ("Error in option 1: " + e.toString ());
}
return sb.toString ();
}


boolean Login (String ID, String password)
{
StringBuffer sb = new StringBuffer ();
try
{
Statement stmt = conn.createStatement ();
ResultSet b = stmt.executeQuery ("SELECT ID, password FROM User WHERE password = '" + password + "'");
while (b.next ())
{
return true;
}
}
catch (Exception e)
{
System.out.println ("Error in option 2: " + e.toString ());
}
return false;
}


public String friend (String name)
{
StringBuffer sb = new StringBuffer ();
try
{
Statement stmt = conn.createStatement ();
name = name.toUpperCase ();
ResultSet rs = stmt.executeQuery ("SELECT name, Surname FROM user WHERE name Like '" + name + "%'");

sb.append ("Search results:");

while (rs.next ())
{
String FirstName = rs.getString ("name");
String surname = rs.getString ("Surname");

sb.append (FirstName + ", " + surname + "\n");

}
stmt.close ();
}
catch (Exception e)
{

}
return sb.toString ();
}
}

if anything else required like the GUI please tell and I will post thanks.