//////////////////////////////////////////////////
//a1.java
public class a1
{
public static String one;
public void thisIsClass1() throws SQLException
{
Connection con = null;
PreparedStatement statement = null;
ResultSet rs = null;
try
{
con = DatabaseFactory.getInstance().getConnection();
//в бд таблица с столбцами (one - nine) в которых по дефолту параментры "333333"
statement = con.prepareStatement("SELECT one FROM table;");
statement.setString(1, "one"); // как я понял здесь в стэйтмент запихивается значение из бд
ResultSet rs = statement.executeQuery();
one = rs.getString("one");
}
catch(Exception e)
{
_log.error("", e);
}
finally
{
DbUtils.closeQuietly(con, statement, rs);
}
}
// ниже в другом методе
public void thisIsClass2()
{
Connection con = null;
PreparedStatement statement = null;
try
{
con = DatabaseFactory.getInstance().getConnection();
// произходят действия при которых меняеться значение "one"
if(1 == 1)
{
statement = con.prepareStatement("UPDATE one FROM table;");
statement.setString(1, "666666"); // как я понимаю здесь присываем данные в "one"
statement.executeUpdate();
;
}
}
catch(Exception e)
{
_log.error("", e);
}
finally
{
DbUtils.closeQuietly(con, statement);
}
}
}
//--------------------------------------------------------------------
//a2.java
import a1;
public class a2
{
public void second()
{
System.out.println(a1.one);
}
}
//////////////////////////////////////////////////