Following on from my previous question I have found the culprit in my code is this object
I have an object called "conn" from the class Connection in Java.
In my old code which works there is no highlighting of the objects name. As you can see below.
However in my newer version of code on Eclipse which does not work due to that object being null all the time the object is highlighted.
My DatabaseLogic class
package org.ari;
//class dependencies
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class DatabaseLogic
{
private static Connection conn;
public static String openDatabase() throws IOException, SQLException,
NamingException
{
// context class gives naming standards of the surrounding environment
// of the servlet i.e. the web server ,
// allowing the servlet to interface with the web servers resources
Context initialContext = new InitialContext();
Context envContext = (Context) initialContext.lookup("java:comp/env");
// servlet looks up for a connection pool called "jdbc/POOL"
DataSource ds = (DataSource) envContext.lookup("jdbc/POOL");
// connection is then made/requests to connection pool
String result = ds.toString();
try
{
conn = ds.getConnection();
}
catch (SQLException e)
{
System.out.println( e.toString());
}
return result;
}
public static void closeDatabase()
{
try
{
conn.close();
}
catch (SQLException e)
{
}
}
// queryId is the parameter to be used for querying for relevant records
// - possibly change name to make it less specific e.g. recordid
public static String getData(String queryId, int requestNumber)
throws SQLException
{
String result = "";
if (queryId != null)
{
try
{
if (conn == null)
{
//result = "We are in here";
result = openDatabase();
}
// prepare a statement for use in query
Statement stmt = conn.createStatement();
// query parameratised with queryId
String qry = "SELECT RECORD_ID, USER_ID, OPERATION_CD, BUSCOMP_NAME, OPERATION_DT, FIELD_NAME, OLD_VAL, NEW_VAL, AUDIT_LOG, ROW_ID, BC_BASE_TBL FROM S_AUDIT_ITEM WHERE RECORD_ID='"
+ queryId + "'";
ResultSet results = stmt.executeQuery(qry);
result = XMLBuilder.xmlBuilder(results, queryId,
requestNumber);
// close the connection
stmt.close();
results.close();
}
catch (Exception e)
{
// log.error("Cannot connect to database :" + e);
}
}
else
{
// not sure if ever reached
result = "The query parameter is a null value";
}
return result;
}
}
What does this highlighting mean, I am guessing eclipse is treating this object in a different way and this is why this object is no longer functioning as it should.
How do I fix this, any ideas? I have tried restoring my older version of code but this highlighting is still the same.
I am guessing it is some setting somewhere in the IDE.
Thanks