1 Reply Latest reply on Apr 15, 2009 8:39 AM by Vicky Kak

    Configuration of data source

    Giuseppe Moscardelli Newbie

      I followed this guide http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Installation_And_Getting_Started_Guide/5/html/Using_other_Databases.html#creating_a_jdbc_client to configure datasource in jboss5 but I receive an errore when I try to execute this jsp page:

      <%@page contentType="text/html"
       DataSource ds = null;
       Connection con = null;
       PreparedStatement pr = null;
       InitialContext ic;
       try {
       ic = new InitialContext();
       ds = (DataSource)ic.lookup( "java:/DefaultDS" );
       con = ds.getConnection();
       pr = con.prepareStatement("select cognome, nome, squadraA from giocatore");
       ResultSet rs = pr.executeQuery();
       while (rs.next()) {
       out.println("<br> " +rs.getString("cognome") + " | " + rs.getString("nome") + " | " +rs.getString("squadraA"));
       }catch(Exception e){
       out.println("Exception thrown " +e);
       if(con != null){
      } %>

      The error tells me that the table 'giocatore' does not exist but the query is correct, if I try it on a the db I receive the correct response.
      So I followd this other guide: http://www.jboss.org/community/wiki/SetUpMysqlAsDefaultDS

      but I have sono problem:
      1) after I deleted $JBOSS_HOME/server/default/deploy/hsqldb-ds.xml and inserted $JBOSS_HOME/docs/examples/jca/mysql-ds.xml in $JBOSS_HOME/server/default/deploy the guide say I have to modify the file $JBOSS_HOME/server/default/conf/standardjaws.xml but in my directory this file does not exist.
      2) I changer in this way:
      java:/DefaultDS <datasource-mapping>mySQL</datasource-mapping> <fk-constraint>true</fk-constraint>
      the text in standardjbosscmp-jdbc.xml
      3) I copied these lines:
      <application-policy name = "MySqlDbRealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal">angelo</module-option> <module-option name = "userName">angelo</module-option> <module-option name ="password">palermo</module-option> <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option> </login-module> </authentication> </application-policy>

      where username and passowrd belongs to the db.
      4)The point 7 of the guide says:
      Replace file $JBOSS_HOME/server/default/deploy/jms/hsql-jdbc2-service.xml by file $JBOSS_HOME/docs/examples/jms/mysql-jdbc2-service.xml

      but the path does not exist in my jboss5 so the point 8 and 9 of the guide are not completed.

      When I try to execute the jsp I receive this error:
      Exception thrown javax.naming.NameNotFoundException: DefaultDS not bound

      So how can I configure datasource?
      Thanks, bye bye.