[jboss-user] [Datasource Configuration] New message: "Re: How to configure Oracle with my application in jboss 5.0"

Anand Kumar do-not-reply at jboss.com
Fri Feb 19 07:19:56 EST 2010


User development,

A new message was posted in the thread "How to configure Oracle with my application in jboss 5.0":

http://community.jboss.org/message/527246#527246

Author  : Anand Kumar
Profile : http://community.jboss.org/people/akstifr

Message:
--------------------------------------------------------------
Here is the Code for database Connection 
 
package beans;
 
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
 
public class OracleDatasource {
    private Connection con;
    
    public Connection getDbConnection() {
        try{
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            DataSource ds = (DataSource)envCtx.lookup("jdbc/datanet);
            if (ds == null)
                System.out.println("datasource not obtained..");
            con= ds.getConnection();
            if (con == null)
                System.out.println("connection not obtained..");
        } catch( NamingException ne ) {
            throw new RuntimeException( "Unable to aquire data source", ne );
        } catch (SQLException se) {
            System.out.println("Exception occured while obtaining connection...");
            se.printStackTrace();
        }
        return con;
    }//end getDbConnection()
}//end class


--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/527246#527246




More information about the jboss-user mailing list