1 Reply Latest reply on Feb 16, 2009 9:57 PM by Peter Johnson

    NameNotFoundException

    Jotnarta Zabin Newbie

      Hi All

      I unzipped JBoss 5 again, and I replaced the default hsql-ds.xml file with mysql-ds.xml, following is my file:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <datasources>
      
       <local-tx-datasource>
      
       <jndi-name>MyDB</jndi-name>
      
       <connection-url>jdbc:mysql://localhost:3306/project</connection-url>
      
       <driver-class>com.mysql.jdbc.Driver</driver-class>
      
       <user-name>root</user-name>
      
       <password>admin</password>
      
       <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
      
       <metadata>
      
       <type-mapping>mySQL</type-mapping>
      
       </metadata>
      
       </local-tx-datasource>
      
      </datasources>
      


      and this is my jsp file:
      <%
       DataSource ds = null;
       Connection con = null;
       //Statement st = null;
       InitialContext ic;
      
       try {
       ic = new InitialContext();
       ds = (DataSource) ic.lookup("java:/MyDB");
       con = ds.getConnection();
       Statement st = con.createStatement();
       DatabaseMetaData md = con.getMetaData();
       ResultSet rs = st.executeQuery("select * from quest_choices;");
       //ResultSet rs = md.getTables(null, null, "%", null);
      
       while(rs.next()) {
       out.println("<br> " + rs.getString("ID"));
       //System.out.println(rs.getString(3));
       }
       rs.close();
       st.close();
      
       out.println("DONE");
       } catch (Exception e) {
       out.println("Exception thrown " + e );
       //e.printStackTrace();
       } finally {
       if (con != null) {
       con.close();
       }
       }
      %>
      


      What's wrong with my code, any help please???