[jboss-user] [Beginners Corner] - NameNotFoundException

jotnarta do-not-reply at jboss.com
Mon Feb 16 16:04:24 EST 2009


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???

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210511#4210511

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210511



More information about the jboss-user mailing list