Re: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Harry Mantheakis
Tom

> In a servlet you have an init() statement
> that executes only once which you get your
> db connection in...

I hope you are not in a fog about this: there is nothing pre-ordained about
getting a connection in a servlet init method - that just happens to be
where your code is.

> also you need to call super.init(config), where
> you don't have to do this in a bean, because it
> is implicit...

Hmm... I think maybe you are in a bit of fog about all this :-)

Calling 'super.init( config )' within a servlet's init method has nothing to
do with database connections.

Anyway, if you are prepared to post the *exact* bean code that is not
working for you, I am prepared to look at it and try to help you.

Posting snippets of code is not good enough.

The alternative is for you to walk through your code (with println
statements, or a debugger) and see where it stops working.

> Next challenge is I have a blob that I
> set and get, but when I get the blob on
> my results page, it comes up with...

Is that the servlet providing the 'results' - or did you fix the bean?

Regards

Harry


> Not exactly...it is not the same! I have it working with a connection
> pool, mySQL and JNDI. To keep my reply short it goes like this within
> the bean:
> getDBConnection(); // get
> the connection
> prepareStatement(); // prepare the
> statement
> rs = pstmt.executeQuery();// execute the
> query
> and of course after that I "get" my parameters. In a servlet you have an
> init() statement that executes only once which you get your db
> connection in, also you need to call super.init(config), where you don't
> have to do this in a bean, because it is implicit.
> 
> (By the way, if someone wants an example, I will post it, but you'll
> then be my wife.)
> 
> Next challenge is I have a blob that I set and get, but when I get the
> blob on my results page, it comes up with something like this  @1eb2473
> which I assume is an address. Anyone know what know how to get, what's
> in the address. Maybe open a "stream"?
> 
> TIA
> 
> Tom K.
> 
> 
> 
> -----Original Message-----
> From: Harry Mantheakis [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 26, 2004 10:43 AM
> To: Tomcat Users List
> Subject: Re: Question on debuggin JNDI/prepared statement in a bean
> 
> Hi Tom
> 
>> how do you set up a JNDI connection
>> in a bean?
> 
> Exactly the same way as you would anywhere else, so if you have some
> code
> working in a servlet, copy it.
> 
> To be precise, it is a database connection, acquired from a DataSource,
> which is itself acquired via a JNDI lookup. The fact that your code is
> in a
> bean makes no difference.
> 
> 
>> how do you... use a prepared statement (in a bean)
> 
> 
> Same as anywhere else.
> 
> 
>> how do you... retrieve a resultset, and
>> forward the result
> 
> 
> Again, same as anywhere else.
> 
> BTW - you should not be passing about references to JDBC objects that
> are
> tethered (so to speak) to database connections - it is bad practice, and
> likely to cause connection (and memory) leaks.
> 
> The best thing to do with database connections is, grab your data, store
> it
> in some collection object, and then make damn sure you close the db
> connection - usually within a 'finally' block which is guaranteed to
> execute, even when exceptions occur.
> 
> Having stored the data you need in a collection object, you can pass
> that
> about as much as you like.
> 
> That has not really answered your original question, but unless you
> provide
> us with all your relevant code we probably cannot solve the problem.
> 
> Since you got it working before, I would be inclined to start again,
> making
> sure that you copy the same JNDI/connection procedures in your 'bean' as
> in
> the servlet that works.
> 
> The fact that your 'bean' is not throwing any exceptions suggests, to
> me,
> that there is a bug (logic error) in your code. Starting over might sort
> that out.
> 
> Sprinkle about a few (temporary) 'System.out.println' statements to see
> where your code gets to. Not cool, but they do the job sometimes!
> 
> If you are using an IDE - like Eclipse - you can run in debug mode, so
> it's
> easy to see what is happening - though may be not with JSPs.
> 
> Good luck.
> 
> Harry
> 
> 
>> Harry,
>> 
>> Yes the ClassifiedAd and UniqueDateId are two parameters taken
>> from an html form, the values of ClassifiedAd and UniqueDateId are
> used
>> in a prepared statement for substitution of ? and ? the results 

RE: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Tom K
Not exactly...it is not the same! I have it working with a connection
pool, mySQL and JNDI. To keep my reply short it goes like this within
the bean:
getDBConnection();  // get
the connection
prepareStatement(); // prepare the
statement
rs = pstmt.executeQuery();  // execute the
query
and of course after that I "get" my parameters. In a servlet you have an
init() statement that executes only once which you get your db
connection in, also you need to call super.init(config), where you don't
have to do this in a bean, because it is implicit.

(By the way, if someone wants an example, I will post it, but you'll
then be my wife.)

Next challenge is I have a blob that I set and get, but when I get the
blob on my results page, it comes up with something like this  @1eb2473
which I assume is an address. Anyone know what know how to get, what's
in the address. Maybe open a "stream"?

TIA

Tom K.



-Original Message-
From: Harry Mantheakis [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 26, 2004 10:43 AM
To: Tomcat Users List
Subject: Re: Question on debuggin JNDI/prepared statement in a bean

Hi Tom

> how do you set up a JNDI connection
> in a bean?

Exactly the same way as you would anywhere else, so if you have some
code
working in a servlet, copy it.

To be precise, it is a database connection, acquired from a DataSource,
which is itself acquired via a JNDI lookup. The fact that your code is
in a
bean makes no difference.


> how do you... use a prepared statement (in a bean)


Same as anywhere else.


> how do you... retrieve a resultset, and
> forward the result


Again, same as anywhere else.

BTW - you should not be passing about references to JDBC objects that
are
tethered (so to speak) to database connections - it is bad practice, and
likely to cause connection (and memory) leaks.

The best thing to do with database connections is, grab your data, store
it
in some collection object, and then make damn sure you close the db
connection - usually within a 'finally' block which is guaranteed to
execute, even when exceptions occur.

Having stored the data you need in a collection object, you can pass
that
about as much as you like.

That has not really answered your original question, but unless you
provide
us with all your relevant code we probably cannot solve the problem.

Since you got it working before, I would be inclined to start again,
making
sure that you copy the same JNDI/connection procedures in your 'bean' as
in
the servlet that works.

The fact that your 'bean' is not throwing any exceptions suggests, to
me,
that there is a bug (logic error) in your code. Starting over might sort
that out.

Sprinkle about a few (temporary) 'System.out.println' statements to see
where your code gets to. Not cool, but they do the job sometimes!

If you are using an IDE - like Eclipse - you can run in debug mode, so
it's
easy to see what is happening - though may be not with JSPs.

Good luck.

Harry


> Harry,
> 
> Yes the ClassifiedAd and UniqueDateId are two parameters taken
> from an html form, the values of ClassifiedAd and UniqueDateId are
used
> in a prepared statement for substitution of ? and ? the results are
then
> forwarded to a results jsp, which used the getXXX() to retrieve the
> values from the bean.
> I have this code working in another form as a Servlet using JNDI
> and prepared statements. In the servlet the JNDI connection is made in
> the init(blah, blah) and calls the super.init(config) which I
> super.init(config) is implicit from reading the Tomcat docs.
> The bottom line on this, is how do you set up a JNDI connection
> in a bean, use a prepared statement (in a bean), retrieve a resultset
> and forward the result for the results jsp to retrieve the value from
> the bean.
> 
> Finally, I apologize to those who feel this is off topic. I have
similar
> code working in Resin but for the life of me, I can't get it working
> with Tomcat 5  :-(   I searched all the archives and can't find a good
> example for doing this.
> 
> TIA Tom K.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---
Incoming 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
 

---
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
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Harry Mantheakis
Hi Tom

> how do you set up a JNDI connection
> in a bean?

Exactly the same way as you would anywhere else, so if you have some code
working in a servlet, copy it.

To be precise, it is a database connection, acquired from a DataSource,
which is itself acquired via a JNDI lookup. The fact that your code is in a
bean makes no difference.


> how do you... use a prepared statement (in a bean)


Same as anywhere else.


> how do you... retrieve a resultset, and
> forward the result


Again, same as anywhere else.

BTW - you should not be passing about references to JDBC objects that are
tethered (so to speak) to database connections - it is bad practice, and
likely to cause connection (and memory) leaks.

The best thing to do with database connections is, grab your data, store it
in some collection object, and then make damn sure you close the db
connection - usually within a 'finally' block which is guaranteed to
execute, even when exceptions occur.

Having stored the data you need in a collection object, you can pass that
about as much as you like.

That has not really answered your original question, but unless you provide
us with all your relevant code we probably cannot solve the problem.

Since you got it working before, I would be inclined to start again, making
sure that you copy the same JNDI/connection procedures in your 'bean' as in
the servlet that works.

The fact that your 'bean' is not throwing any exceptions suggests, to me,
that there is a bug (logic error) in your code. Starting over might sort
that out.

Sprinkle about a few (temporary) 'System.out.println' statements to see
where your code gets to. Not cool, but they do the job sometimes!

If you are using an IDE - like Eclipse - you can run in debug mode, so it's
easy to see what is happening - though may be not with JSPs.

Good luck.

Harry


> Harry,
> 
> Yes the ClassifiedAd and UniqueDateId are two parameters taken
> from an html form, the values of ClassifiedAd and UniqueDateId are used
> in a prepared statement for substitution of ? and ? the results are then
> forwarded to a results jsp, which used the getXXX() to retrieve the
> values from the bean.
> I have this code working in another form as a Servlet using JNDI
> and prepared statements. In the servlet the JNDI connection is made in
> the init(blah, blah) and calls the super.init(config) which I
> super.init(config) is implicit from reading the Tomcat docs.
> The bottom line on this, is how do you set up a JNDI connection
> in a bean, use a prepared statement (in a bean), retrieve a resultset
> and forward the result for the results jsp to retrieve the value from
> the bean.
> 
> Finally, I apologize to those who feel this is off topic. I have similar
> code working in Resin but for the life of me, I can't get it working
> with Tomcat 5  :-(   I searched all the archives and can't find a good
> example for doing this.
> 
> TIA Tom K.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Adrian Lanning
Hey Tom,

When I said your thread was off-topic I didn't mean to imply you couldn't
post your question!  Sorry if that's how it came across.  Just thought you
should mark it [OT] as Yoav pointed out. It appears I was wrong anyways; I
missed the part about it working in Resin and not in Tomcat.

As for your question, what is it exactly that goes wrong with your app now
that its running under Tomcat and not Resin?  Trouble getting the data to
your jsp?  Is it not starting up?  The code you posted doesn't actually DO
anything so I'm guessing that's just an example you put together to
illustrate what you're trying to do?

Could you post the parts of your Context regarding the jndi resource you are
configuring?

Adrian

- Original Message - 
From: "Tom K" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Friday, March 26, 2004 9:41 AM
Subject: RE: Question on debuggin JNDI/prepared statement in a bean


Harry,

Yes the ClassifiedAd and UniqueDateId are two parameters taken
from an html form, the values of ClassifiedAd and UniqueDateId are used
in a prepared statement for substitution of ? and ? the results are then
forwarded to a results jsp, which used the getXXX() to retrieve the
values from the bean.
I have this code working in another form as a Servlet using JNDI
and prepared statements. In the servlet the JNDI connection is made in
the init(blah, blah) and calls the super.init(config) which I
super.init(config) is implicit from reading the Tomcat docs.
The bottom line on this, is how do you set up a JNDI connection
in a bean, use a prepared statement (in a bean), retrieve a resultset
and forward the result for the results jsp to retrieve the value from
the bean.

Finally, I apologize to those who feel this is off topic. I have similar
code working in Resin but for the life of me, I can't get it working
with Tomcat 5  :-(   I searched all the archives and can't find a good
example for doing this.

TIA Tom K.






-Original Message-
From: Harry Mantheakis [mailto:[EMAIL PROTECTED]
Sent: Friday, March 26, 2004 2:29 AM
To: Tomcat Users List
Subject: Re: Question on debuggin JNDI/prepared statement in a bean

Hello

> pstmt.setString(1,ClassifiedAd);
> pstmt.setString(2,UniqueDateId);

Are those two parameters - 'ClassifiedAd' and 'UniqueDateId' -
variables?
They should be, and if so, where do you declare and initialise them?
They do
not appear in the method you posted.

Harry


> 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
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---
Incoming 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


---
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



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Tom K
Harry,

Yes the ClassifiedAd and UniqueDateId are two parameters taken
from an html form, the values of ClassifiedAd and UniqueDateId are used
in a prepared statement for substitution of ? and ? the results are then
forwarded to a results jsp, which used the getXXX() to retrieve the
values from the bean.
I have this code working in another form as a Servlet using JNDI
and prepared statements. In the servlet the JNDI connection is made in
the init(blah, blah) and calls the super.init(config) which I
super.init(config) is implicit from reading the Tomcat docs.
The bottom line on this, is how do you set up a JNDI connection
in a bean, use a prepared statement (in a bean), retrieve a resultset
and forward the result for the results jsp to retrieve the value from
the bean.

Finally, I apologize to those who feel this is off topic. I have similar
code working in Resin but for the life of me, I can't get it working
with Tomcat 5  :-(   I searched all the archives and can't find a good
example for doing this.

TIA Tom K.



   


-Original Message-
From: Harry Mantheakis [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 26, 2004 2:29 AM
To: Tomcat Users List
Subject: Re: Question on debuggin JNDI/prepared statement in a bean

Hello

> pstmt.setString(1,ClassifiedAd);
> pstmt.setString(2,UniqueDateId);

Are those two parameters - 'ClassifiedAd' and 'UniqueDateId' -
variables?
They should be, and if so, where do you declare and initialise them?
They do
not appear in the method you posted.

Harry


> 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
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---
Incoming 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
 

---
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
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Shapira, Yoav

Hi,
This is a fine list, and he'd get a ton of help anyways.  He should just
mark the subject as [OFF-TOPIC].

Yoav Shapira
Millennium Research Informatics


>-Original Message-
>From: Adrian Lanning [mailto:[EMAIL PROTECTED]
>Sent: Friday, March 26, 2004 7:01 AM
>To: Tomcat Users List
>Subject: Re: Question on debuggin JNDI/prepared statement in a bean
>
>This topic doesn't really have anything to do with Tomcat so you might
have
>better luck receiving help on some other mailing list.  Anybody know
which
>list he should be posting to?
>
>What is the actual problem you are having?
>
>Do you execute your prepared statement somewhere?
>
>Adrian
>
>
>- Original Message -
>From: "Harry Mantheakis" <[EMAIL PROTECTED]>
>To: "Tomcat Users List" <[EMAIL PROTECTED]>
>Sent: Friday, March 26, 2004 3:28 AM
>Subject: Re: Question on debuggin JNDI/prepared statement in a bean
>
>
>Hello
>
>> pstmt.setString(1,ClassifiedAd);
>> pstmt.setString(2,UniqueDateId);
>
>Are those two parameters - 'ClassifiedAd' and 'UniqueDateId' -
variables?
>They should be, and if so, where do you declare and initialise them?
They
>do
>not appear in the method you posted.
>
>Harry
>
>
>> I am frustrated trying to debug a prepared statement within a bean;
what
>> am I doing wrong?; ANY clues appreciatedS
>> 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
>>
>>
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Adrian Lanning
This topic doesn't really have anything to do with Tomcat so you might have
better luck receiving help on some other mailing list.  Anybody know which
list he should be posting to?

What is the actual problem you are having?

Do you execute your prepared statement somewhere?

Adrian


- Original Message - 
From: "Harry Mantheakis" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Friday, March 26, 2004 3:28 AM
Subject: Re: Question on debuggin JNDI/prepared statement in a bean


Hello

> pstmt.setString(1,ClassifiedAd);
> pstmt.setString(2,UniqueDateId);

Are those two parameters - 'ClassifiedAd' and 'UniqueDateId' - variables?
They should be, and if so, where do you declare and initialise them? They do
not appear in the method you posted.

Harry


> I am frustrated trying to debug a prepared statement within a bean; what
> am I doing wrong?; ANY clues appreciatedS
> 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
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Question on debuggin JNDI/prepared statement in a bean

2004-03-26 Thread Harry Mantheakis
Hello

> pstmt.setString(1,ClassifiedAd);
> pstmt.setString(2,UniqueDateId);

Are those two parameters - 'ClassifiedAd' and 'UniqueDateId' - variables?
They should be, and if so, where do you declare and initialise them? They do
not appear in the method you posted.

Harry


> 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
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Question on debuggin JNDI/prepared statement in a bean

2004-03-25 Thread Tom K
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