2 Replies Latest reply on Jul 3, 2006 5:27 AM by Bob Graham

    NamingException caught jdbc:mysql: not bound, what is wrong?

    Bob Graham Newbie

      Hey,
      I'm using jboss 4.0.3 with mysql 4.1 & connector mysql-connector-java-3.0.17-ga.jar

      in my ../server/default/mysql-ds.xml I got:


      <local-tx-datasource>
      <jndi-name>DefaultDS</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>jboss</user-name>
      password
      </local-tx-datasource>


      and I have written a program using jsp and javabeans where a javabean tries to connect to the database and retrieve some info and display it

      the part of the bean that connects look like:

      public void goConnect() {

      Context env = null;
      DataSource source = null;

      try {
      env = new InitialContext();
      source = (DataSource)env.lookup("jdbc:mysql://localhost:3306/test");


      } catch(NamingException e) {
      System.out.println("NamingException caught " +e.getMessage());
      }

      try{


      Connection con = source.getConnection();

      Statement s = con.createStatement();

      String sql = "select * from items where name = 'cykel'";

      ResultSet rs = s.executeQuery(sql);

      setBaseName(rs.getString("seller"));

      s.close();
      con.close();
      }

      what can be wrong?