[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
Wed Feb 24 02:19:00 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/528099#528099
Author : Anand Kumar
Profile : http://community.jboss.org/people/akstifr
Message:
--------------------------------------------------------------
Previously i used jdbc/datanet but after you have specified some changes in the previous post so that i have changed that thing in the code with new name. Here is Connection Code file:
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)initCtx.lookup("java:comp/env/jdbc/OracleDS");
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/528099#528099
More information about the jboss-user
mailing list