i will try this out again i think i have followed more or less the same
procedure. but can u tell me if i want to access the datasource from a
simple java application can i do that. i should be able to get it from the
same jndi context shouldnt i be able to do that? please let me know.
thanks and regards,
alap.
----- Original Message -----
From: "Torsten Terp" <[EMAIL PROTECTED]>
To: "jBoss" <[EMAIL PROTECTED]>
Sent: Saturday, December 02, 2000 3:04 PM
Subject: SV: [jBoss-User] Problem with finding jdbc pool from jndi
> Hi,
>
> This is an earlier post on the subject that you might want to take a look
> at!
>
> ============(snip)================
>
> Ok here goes:
>
> In jboss.conf I specify a datasource:
>
> <MLET CODE="org.jboss.jdbc.XADataSourceLoader"
> ARCHIVE="jboss.jar, interclient-core.jar"
> CODEBASE="../../lib/ext/">
> <ARG TYPE="java.lang.String" VALUE="InterBase">
> <ARG TYPE="java.lang.String"
> VALUE="org.jboss.minerva.xa.XADataSourceImpl">
> </MLET>
>
> The important thing here is its name "InterBase"
>
> This name is again used in the mbean definition in
> jboss.jcml:
>
> <mbean
> name="DefaultDomain:service=XADataSource,name=InterBase">
> <attribute name="Properties"></attribute>
> <attribute
> name="URL">jdbc:interbase://localhost/e:/tmp/gdb.gdb</attribute>
> <attribute name="GCMinIdleTime">1200000</attribute>
> <attribute name="JDBCUser">xxx</attribute>
> <attribute name="MaxSize">0</attribute>
> <attribute name="Password">yyy</attribute>
> <attribute name="GCEnabled">false</attribute>
> <attribute
> name="InvalidateOnError">false</attribute>
> <attribute name="TimestampUsed">false</attribute>
> <attribute name="Blocking">true</attribute>
> <attribute name="GCInterval">120000</attribute>
> <attribute name="IdleTimeout">1800000</attribute>
> <attribute
> name="IdleTimeoutEnabled">false</attribute>
> <attribute name="LoggingEnabled">false</attribute>
> <attribute
> name="MaxIdleTimeoutPercent">1.0</attribute>
> <attribute name="MinSize">0</attribute>
> </mbean>
>
> in standardjaws.xml I have the following datasource:
>
> <datasource>java:/InterBase</datasource>
>
> In my ejb-jar.xml I add a resource of type datasource
> to the bean using it:
> The name used here is "jdbc/DBPool" which will make
> the lookup (when used
> in a bean) look like "java:comp/env/jdbc/DBPool"
>
> <session>
> <ejb-name>ItemManagerEJB</ejb-name>
>
> <home>com.netmill.cityshop.interfaces.item.ItemManagerEJBHome</home>
>
> <remote>com.netmill.cityshop.interfaces.item.ItemManagerEJB</remote>
>
> <ejb-class>com.netmill.cityshop.ejb.item.ItemManagerEJBBean</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Bean</transaction-type>
> <resource-ref>
> <description>DataSource connected to the cityshop
> database.</description>
> <res-ref-name>jdbc/DBPool</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </session>
>
>
> In jboss.xml I add a resource manager for the
> application, it gets bound to
> "InterBase" specified in jboss.conf:
>
> <resource-managers>
> <resource-manager
> res-class="org.jboss.ejb.deployment.JDBCResource">
> <res-name>CityShopDataSourceManager</res-name>
> <res-jndi-name>InterBase</res-jndi-name>
> </resource-manager>
> </resource-managers>
>
> and again in jboss.xml I add the resource for the bean
> which is using the datasource
>
> <session>
> <ejb-name>ItemManagerEJB</ejb-name>
> <jndi-name>item/ItemManager</jndi-name>
> <configuration-name></configuration-name>
> <resource-ref>
> <res-ref-name>jdbc/DBPool</res-ref-name>
>
> <resource-name>CityShopDataSourceManager</resource-name>
> </resource-ref>
> </session>
>
> By now I should have a naming chain like this going:
>
> java:comp/env/jdbc/DBPool -> CityShopDataSourceManager
> -> InterBase
>
> so finnally in the bean code I can use something like:
>
> Context ctx = new InitialContext();
> Connection conn = null;
> try {
> DataSource ds =
> (DataSource)ctx.lookup("java:comp/env/jdbc/DBPool");
> conn = ds.getConnection();
> System.out.println("Yahooo... got it!!! :-)");
> } catch(NamingException ne) {
> System.out.println("NamingException caught:" +
> ne.getMessage());
> } catch(SQLException se) {
> System.out.println("SQLException caught:" +
> se.getMessage());
> } finally {
> if(conn != null)
> try {
> conn.close();
> } catch(SQLException e){}
> }
>
> to get "Yahooo... got it!!! :-)" printed to standard
> out :-)
>
> Hope it helps...
>
> ^torsten
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Problems?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]