2 Replies Latest reply on May 17, 2006 1:27 PM by Feris Thia

    About DataSource JNDI

    Feris Thia Newbie

      Hi All,

      I set up mysql data source (msql-ds.xml) like below

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
      <!-- Datasource config for MySQL using 3.0.9 available from:
      http://www.mysql.com/downloads/api-jdbc-stable.html
      -->
      
      <datasources>
       <local-tx-datasource>
       <jndi-name>MySqlDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/classicmodels</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password></password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
       -->
       <!-- sql to call on an existing pooled connection when it is obtained from pool
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
       -->
      
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      


      and succeed access it within the same computer with the following code snippets

       Properties props = new Properties();
       props.setProperty(
       "java.naming.factory.initial",
       "org.jnp.interfaces.NamingContextFactory"
       );
       props.setProperty(
       "java.naming.provider.url",
       "localhost:1099"
       );
      
       InitialContext jndiContext = new InitialContext(props);
      
       DataSource ds = (DataSource) jndiContext.lookup("java:MySqlDS");
      
       .....
      


      It's working fine.... but when I move my code to another computer and change the java.naming.provider.url to my computer ip address (192.168.100.33) as shown below

      
       props.setProperty(
       "java.naming.provider.url",
       "192.168.100.33:1099"
       );
      
      


      It gets error something about "not bound... " I forget the error details, cause now I'm using my notebook and have no other computer to connect with. But I experienced this at the office.

      What I'm asking is, am I writing a right code ? Is that possible to access data source JNDI resources through network ? Because I don't have any problem when using EJB with JNDI.

      Regards,

      Feris