aspose file tools*
The moose likes JBoss/WildFly and the fly likes How to configure Datasource in JBOSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to configure Datasource in JBOSS" Watch "How to configure Datasource in JBOSS" New topic

How to configure Datasource in JBOSS

Rajani kanth Anupoju

Joined: Feb 26, 2004
Posts: 1
I am getting "datasource not bound" exception.Please help me to solve this.I have given the following details:

My datasource connection name is OracleDS.I have put that xml in server/default/deploy folder as oracle-ds.xml and classes12.jar folder.

In web.xml,i have included the following:

<description>DB Connection</description>

In jboss-web.xml,

I have put the spring jars and jar files in the lib folder of WEB-INF

In a jsp file when i try to access like this
String sql = "select * from emp";

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ResultSetMetaData rsm = null;
Properties env = new Properties();

Context ctx = new InitialContext(env);
DataSource datasource= (DataSource) ctx.lookup("java:/OracleDS");
Connection con=datasource.getConnection();
stmt = conn.createStatement( );
rs = stmt.executeQuery(sql);
rsm = rs.getMetaData( );
int colCount = rsm.getColumnCount( );

I am getting error as follows,
javax.naming.NameNotFoundException: OracleDS not bound
org.jnp.server.NamingServer.getObject(NamingServer .java:505)
org.jnp.server.NamingServer.lookup(NamingServer.ja va:278)
javax.naming.InitialContext.lookup(InitialContext. java:347)
org.apache.jsp.one_jsp._jspService(org.apache.jsp. one_jsp:66)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(
org.apache.jasper.servlet.JspServlet.serviceJspFil e(
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(

Please help me to solve this..........
Pauline McNamara

Joined: Jan 19, 2001
Posts: 4012
Oops, looks like this didn't land in the right forum. Moving it over to the JBoss forum...
I agree. Here's the link:
subject: How to configure Datasource in JBOSS
Similar Threads
DataSource is Null in JNDI Connection with Tomcat
Problem with look up JNDI on JBOSS
JBOSS connection pooling
JBoss JSTL Datasource issue
JBoss 3.2 and MySQL - Could not dereference DataSource object