import java.sql.*;
import java.io.*;
class computerFault
{
	public String computerFaultLevel(String mcName)
	{
		String odbc = "jdbc:odbc:MS Access Database;";
		String db= "system.mdb";
		String url = odbc + db;
		String driver ="sun.jdbc.odbc.JdbcOdbcDriver";
        Connection con;
        String createString;
        createString = "select tblFault.FaultLevel from tblFault WHERE (((tblFault.ComputerName)='"+mcName+"'));";
		int Level=-1;
        Statement stmt;
        try 
		{
            Class.forName(driver);
        } 
		catch(java.lang.ClassNotFoundException e) 
		{
        	System.err.print("ClassNotFoundException: ");
        	System.err.println(e.getMessage());
        }

        try 
		{
            con = DriverManager.getConnection(url);
            stmt = con.createStatement();
			stmt.executeQuery(createString);
			ResultSet rs = stmt.executeQuery(createString);
			while (rs.next()) 
			{
				Level=rs.getInt("FaultLevel");
			}
            stmt.close();
            con.close();
        } 
		catch(SQLException ex) 		
		{
            System.err.println("SQL Exception: " + ex.getMessage());
        }
		String temp="";
		if (Level==0)
		{
			temp="green.gif";
		}
		else if (Level==1)
		{
			temp="amber.gif";
		}
		else if (Level==2)
		{
			temp="red.gif";
		}
		return(temp);
    }

}
