I'm trying to get results from DB
String strCommand = "select TO_CHAR (realdate, 'YYYYMMDD'), PURCHASE_PRICE, SELLING_PRICE from CURRENCY_VI where RATE_NAME='EUR'";
cs.setQueryTimeout(m_nTimeout);
ResultSet rs = cs.executeQuery(strCommand);
while (rs.next()){
System.out.println("!!!\n\nDATE = " + rs.getString("realdate") + " PURCHASE_PRICE = " + rs.getString("PURCHASE_PRICE") + " SELLING_PRICE = " + rs.getString("SELLING_PRICE"));
}
It says that rs.getString("realdate")
- "java.sql.SQLException: invalid column name", why?
Without rs.getString("realdate")
everything works fine.
Actually, table has this column
CREATE TABLE "GPB"."CURRENCY_VI"
( "REALDATE" DATE,
"PURCHASE_PRICE" FLOAT(126),
"SELLING_PRICE " FLOAT(126),
"RATE_NAME" VARCHAR2(20 BYTE)
)
Thank you!
I think you are not selecting realdate
. You are selecting TO_CHAR (realdate, 'YYYYMMDD')
, and that column gets that name. You could do something like this:
TO_CHAR (realdate, 'YYYYMMDD') as myrealdate
and select that. (with `rs.getString("myrealdate")
ofcourse, not with realdate
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With