*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to configure Datasource in JBOSS" Watch "How to configure Datasource in JBOSS" New topic
Author

How to configure Datasource in JBOSS

Rajani kanth Anupoju
Greenhorn

Joined: Feb 26, 2004
Posts: 1
Hi,
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:

<resource-ref>
<description>DB Connection</description>
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

In jboss-web.xml,
<jboss-web>
<resource-ref>
<res-ref-name>OracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/OracleDS</jndi-name>
</resource-ref>
</jboss-web>

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();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");

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.getBinding(NamingServe r.java:491)
org.jnp.server.NamingServer.getBinding(NamingServe r.java:499)
org.jnp.server.NamingServer.getObject(NamingServer .java:505)
org.jnp.server.NamingServer.lookup(NamingServer.ja va:278)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:610)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:572)
javax.naming.InitialContext.lookup(InitialContext. java:347)
org.apache.jsp.one_jsp._jspService(org.apache.jsp. one_jsp:66)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


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

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