I\'m using Websphere Portal 7.0 and creating a portlet with RAD 8.0. My portlet is trying to make a db2 connection to a remote server. I wrote a java program locally to do a
Find below code to get database connection from your web app server. Just create datasource in app server and use following code to get connection :
// To Get DataSource
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/abcd");
// Get Connection and Statement
Connection c = ds.getConnection();
stmt = c.createStatement();
Import naming and sql classes. No need to add any xml file or to edit anything in project.
That's it..