• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Configuring MYSQL Datasource

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am trying to get a hold of mysql datasource and it throws a NameNotBoundException.
here is the code snippet which i am using

Hashtable default_properties = new Hashtable();
default_properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
default_properties.put(Context.PROVIDER_URL,"localhost:1099");
Context context = new InitialContext(default_properties);
DataSource ds = (DataSource) context.lookup("java:/MySqlDS");
java.sql.Connection con = ds.getConnection();

the following is the mysql-ds.xml file
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/mysql</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>danira</password>
</local-tx-datasource>
</datasources>
and i also changed teh standardjaws.xml to
<!--<datasource>java:/DefaultDS</datasource>
<type-mapping>Hypersonic SQL</type-mapping>-->
<datasource>java:/MySqlDS</datasource>
<type-mapping>mySQL</type-mapping>
and also standardjbosscmp-jdbc.xml to
<!--<datasource>java:/DefaultDS</datasource>
<datasource-mapping>Hypersonic SQL</datasource-mapping>-->
<datasource>java:/MySqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>
and copied the mysql-connector-java...jar file under lib folder
and also added an application policy for MsSqlDbRealm in login-config.xml
Could figure what else exactly i need to do.
the last thing i have to mentionis that i have a CMP which uses this datasource and it works but when i want to grab aconnection using this datasource it doesn't. i hope it is clear
Thanks
RASHID
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic