Portlet Question
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > Portlet Question




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Portlet Question  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-31-07 06:21 PM

I'm new to Java and even newer to WebSphere so please pardon my newbiness. I
s it <i>wrong</i> to call a datasource you've created in WAS directly from a
 portlet?
Also, in this following snippet of code what does "comp" and "env" represent
 in the string?

<code>
Context initialContext = new InitialContext();
javax.sql.DataSource myDS =
(javax.sql.DataSource) initialContext.lookup(
"java:comp/env/jdbc/DB2DataSource");

// create a connection from the Data Source
Connection connection = myDS.getConnection();

// create a query from the connection
java.sql.Statement query =
connection.createStatement();
<code>

Thanks for reading.





[ Post a follow-up to this message ]



    Re: Portlet Question  
Jessica Garcia-Glennie


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-31-07 06:21 PM

It's not wrong per se, but it's a lot more common to separate JDBC code into
 another layer that sits behind your portlet.  Do you know much about persis
tence or the MVC pattern?  This tutorial has my bible for a loooong time:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

The sun site also has a good tutorial on JDBC, but what you use as a jndi na
me (that string with /comp/env) is arbitrary.  As for WAS, there is an infoc
enter, just like there is in Portal, and this link has a "How Do I?" section
 which includes "How do I p
rovide access to relational databases (JDBC resources) with the console?"

http://publib.boulder.ibm.com/infoc...owdoi_tadm.html

Good luck,
Jaye





[ Post a follow-up to this message ]



    Re: Portlet Question  


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-31-07 06:21 PM

Thank you so much - you rock! 





[ Post a follow-up to this message ]



    Re: Portlet Question  
Jessica Garcia-Glennie


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-31-07 06:21 PM

teehee Excellent, thanks - a lovely compliment, even if it is from a Gator.

Jaye "Nole" Garcia-Glennie





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:47 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register