I am frustrated trying to debug a prepared statement within a bean; what
am I doing wrong?; ANY clues appreciated…
It is not throwing any exceptions yet I methodically went over the code;
granted this is the first time I used beans versus servlets.
Can anyone point me to a good example (JNDI, JSP, JavaBean, Resultset)
Code within bean:
private void prepareStatement(){
try{
Context env = (Context) new
InitialContext().lookup("java:comp/env");
pool = (DataSource) env.lookup("jdbc/myDB");
if (pool == null)
throw new NamingException("`jdbc/ myDB ' is an
unknown DataSource");
//dbConnection = null;
dbConnection = pool.getConnection();
String SQLCmd =
"select * from AdInfoView where Classification = ?
"
+ "and UniqueDateId < ? order by UniqueDateId
desc";
pstmt = dbConnection.prepareStatement(SQLCmd);
// TEST Exception thrown here.
// pstmt.setString(1,searchWord);
pstmt.setString(1,ClassifiedAd);
pstmt.setString(2,UniqueDateId);
}catch(Exception e){
System.err.println("Problem preparing statement " +
e.getMessage() + e.getCause());
}
}
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003