Hi,
I am facing a problem in simple
JDBC. I have one class where I have declared a
String variable to collect some data form DB(Oracle 9i). I want to reuse those data out side of the method but inside of the same class. But its returning null. please verify the code and let me know where I can improve.
<Code>
public class Test{
public Vector ogetData(){
try{
Connection loConnection = null;
Statement loStmt = null;
ResultSet loRS = null;
loConnection = ogetConnection(CTPUIConstants.CONNECTION_POOL_NAME); // I am collecting this connection object from a connection pool.I am damn sure those codes are find with no error and exception.
String message = "";
StringBuffer loQuery = new StringBuffer();
loQuery.append("SELECT CCY_CODE,MARKET_CODE,AUTHORIZATION_ID,INCLUDE_IN_TP,INCLUDE_IN_LP FROM TB_LP_DERIVED_CALENDAR ");
loStmt = loConnection.createStatement();
loRS = loStmt.executeQuery(loQuery.toString());
while(loRS.next())
{
Vector loCVector = loRS.getString(1);
Vector loMVector = loRS.getString(2);
boolean lbITP = loRS.getString(3);
boolean lbILP = loRS.getString(4);
message = loCVector .toString()+loMVector .toString()+lbITP .toString()+lbILP .toString();
}}
catch (Exception e){e.printStackTrace();}
finally{
lors.close();
loStmt.close();
loConnection.close();
}
return loCVector ;
return loMVector ;
}
public void printMessge(){
System.out.println("The message from DB is :" +message);
}
public inti(){
Test t1 = new Test();
t1.ogetData();
t1.printMessage();
}
<Code>
When I tried to print the value of that String "message" its getting blank. I want those values to be append in that. please suggest.
}