Thanks a lot. Danch. Now, I am using: ctx.lookup("java:/Customer") and change
"java:/DefaultDS" to "java:/Customer", my lookup code works fine. So I assumed if i
change "java:/Customer" back to "java:/DefaultDS", I also can lookup for
"java:/DefaultDS".
I will try to use "java:comp/env/jdbc/Custmoer" and the old setting later.
danch wrote:
> You're close! See comments inline below.
>
> -danch
>
> Christine wrote:
>
> > Sorry for miscopy in my previous email!
> >
> > The code in my function is :
> > javax.naming.Context ctx = new InitialContext();
> > DataSource dbs = (DataSource) ctx.lookup("jdbc/Customer");
>
> the name should be "java:comp/env/jdbc/Customer".
>
> The 'java:comp/env' is the "Environment Naming Context" that the J2EE
> spec specifies that the container provide for all components. The
> res-ref-name of anything you list in an ejb-ref or a resource-ref gets
> put within that.
>
> > Connection aConnection = dbs.getConnection();
> > Statement QStatment = aConnection.createStatement();
> > ResultSet Result = QStatment.executeQuery("select max(ID) from
> > customer");
> >
> > And I specified the resource reference in both web.xml and jboss-web.xml
> >
> > as following:
> > 1. web.xml
> > <resource-ref>
> > <description> The default DS </description>
> > <res-ref-name>java:/DefaultDS</res-ref-name>
>
> This is where you say 'jdbc/Customer'
>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> > 2. jboss-web.xml
> > <jboss-web>
> > <resource-ref>
> > <res-ref-name>java:/DefaultDS</res-ref-name>
>
> 'jdbc/Customer' again.
>
> > <res-type>javax.sql.DataSource</res-type>
> > <jndi-name>jdbc/Customer</jndi-name>
>
> And that's where 'java:/DefaultDS' goes.
>
> > </resource-ref>
> > </jboss-web>
> > 3. the JDBC part in jboss.jcml file is:
> > <mbean code="org.jboss.jdbc.XADataSourceLoader"
> > name="DefaultDomain:service=XADataSource,name=MySQLDS">
> > <attribute name="PoolName">DefaultDS</attribute>
> > <attribute
> > name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
> >
> > <attribute name="URL">jdbc:mysql://localhost/Customer</attribute>
> > <attribute name="JDBCUser">root</attribute>
> >
> > 4. the jaws.xml file is :
> > <jaws>
> > <datasource>java:/DefaultDS</datasource>
> > <type-mapping>mySQL</type-mapping>
> >
> > Now, I am getting error: jdbc not bound. Would anyone tell me what
> > mistakes I made? Any suggestion will be appreciated!
> >
> > Regards,
> >
> > --
> > Jia (Christine) Li
> >
> > 524N ICT Building
> > Department of Computer Science
> > University of Calgary
> >
> >
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-user
> >
--
Jia (Christine) Li
524N ICT Building
Department of Computer Science
University of Calgary
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user