Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to configure Datasource in JBOSS

 
Rajani kanth Anupoju
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, looks like this didn't land in the right forum. Moving it over to the JBoss forum...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic