Home | Login | Blog | Forum | Download | RSS Feed | Ajax | Hello-World | J2EE | BPM | EJB | FileNet | Hibernate | ORM | IBM | ILOG | Interview | FAQs |

Java | Apache | JVM | Others | BRMS | Oracle | Pega | SOA | Sun-Certification | Web-Service | websphere | XML |
 

JAVA DEVELOPER SITE - COMPLETE JAVA TUTORIALS

Access Data Source from Java Client Code in Websphere-application-server


Share
 
 

Useful Java Links


       


The below code gets a connection from the websphere application server for a created data source.

___________________________________________________________

package com.iewf.resource;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.sql.DataSource;

public class DataSourceHelper {

public static void main(String args[]) throws NamingException, SQLException{

InitialContext ctx = new InitialContext();

javax.sql.DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/myDS");

//where jdbc/myDS is the name of the resource reference

//java.sql.Connection conn1 = ds.getConnection();

java.sql.Connection conn = ds.getConnection("user", "password");

//where user and password are the user id and password for the connection

Statement stmt = conn.createStatement();

String query = "";

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

//firstNameList.addElement(rs.getString(1));

}

conn.close();

}

}




Download Latest Java/J2EE eBooks, SCJP Dumps, SCWCD Dumps, Pega Tutorial, IBM WebSphere BPM tutorials and many more


If you need any urgent assistance on java-client-code-to-access-websphere-data-source, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.

You can also subscribe to our newsletters on java-client-code-to-access-websphere-data-source, to receive updates on java-client-code-to-access-websphere-data-source,via email.Enter you email below:

Enter your email address:

Delivered by FeedBurner



Keyword Tags: java-client-code-to-access-websphere-data-source tutorial,java-client-code-to-access-websphere-data-source in java,Concepts of java-client-code-to-access-websphere-data-source,Java,J2EE,Interview Questions,java-client-code-to-access-websphere-data-source Examples


Comments:


Post Your Comment:

*

Yes, I would like to recieve email notifications on my reply.

Popular Posts:

 
Popular Downloads

SCJP 1.6 Dumps
JSP Interview Questions
Struts Interview Questions
Hibernate Interview Questions
SCWCD Dumps
SCBCD Dumps

Java/J2EE Tutorial
JMS Tutorials
seam richfaces tutorial
richfaces live demo
jquery example demo
JQuery Tutorial and Source Code
JSF Tutorial
XSL Tutorial
J2EE JMS
CORBA Applications
Java CERTIFICATION
SCJP 1.5
SCJP 1.6
SCWCD 1.5
SCBCD
Mis
Ajax autosuggest autocomplete from database
Struts forms and validation with webflow
Java Apache POI Examples
JDBC Tutorial
Oracle 9i & 10g
MYSQL Tutorial
php Tutorial
JQuery Examples
Upload Java File
JAXB Examples
PL-SQL Tutorial
Dojo AJAX
EJB Examples
Java IDE
Eclipse
NetBeans
IBM Rational Weblogic Workshop
Downloads
SCJP 1.6 Dumps
SCJP 1.5 DUMP
SCJP Material
SCWCD
Java Security
SCBCD Dumps
External Links
SUN Java
JOracle
IBM
PHP Certification
Technical Interview Questions
Amazon Interview Questions
Google Interview Questions
Microsoft Interview Questions
IBM Interview Questions
Yahoo Interview Questions
All Tutorials
php mysql tutorial
SCJP 1.5/1.6
SCWCD 1.5/1.6
Polymorphism
Thread Tutorial
Generics & Exceptions
Spring Struts Hibernate
Java Collections
MAP
SET
LIST
VECTOR
Advanced Java
Stateless Session Bean
Introduction to EJB
Stateful Session Bean
Java Design Patterns
HOME | FORUM | ABOUT | BLOGS | CONTACT-US