[jboss-user] [JCA/JBoss] - MySQL Datasource on JBoss

jotnarta do-not-reply at jboss.com
Thu Feb 26 07:23:52 EST 2009


Hi All

Any one know how to configure a mysql datasource in JBoss??? I am using JBoss 5 and mysql 5, I tried everything, and read everything,  :argh:, can anyone help me , pleassssssssse... I always get the following error 
  Exception thrown java.sql.SQLException: Table not found in statement [select * from questions]   

following is my mysql-ds.xml file:
  <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <datasources>
  | 
  |     <local-tx-datasource>
  | 
  |     <jndi-name>DefaultDS</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 following is my client:
  <%@page import="java.util.*,javax.naming.*,javax.sql.DataSource,java.sql.*"%>
  | <%
  | 	DataSource ds = null;
  | 	Connection con = null;
  | 	//Statement st = null;
  | 	InitialContext ic;
  | 	
  | 	try {
  | 		ic = new InitialContext();
  | 		ds = (DataSource) ic.lookup("java:DefaultDS");
  | 		con = ds.getConnection();
  | 		//out.println( "Connection: " + con. );
  | 		
  | 		Statement st = con.createStatement();
  | 		//DatabaseMetaData md = con.getMetaData();
  | 		
  | 		out.println(" Username: " + md.getUserName());
  | 		
  | 		ResultSet rs = st.executeQuery("select * from questions");
  | 		//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();
  | 		}
  | 	}
  | %>  

Another questions is, do i have to change something in other files??  and where can i find the log for JBoss server???

Any help please???

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

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



More information about the jboss-user mailing list