[jboss-user] [Beginners Corner] - Re: SQLException
jotnarta
do-not-reply at jboss.com
Mon Feb 16 11:30:16 EST 2009
Thank you Peter. I removed the file called hsql-db.xml, I changed my mysql-db.xml datasource to be MyDB, and I changed my jsp file.
mysql-ds.xml 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>
|
I changed my jsp file to be:
| try {
| ic = new InitialContext();
| ds = (DataSource) ic.lookup("java:/MyDB");
| con = ds.getConnection();
| Statement st = con.createStatement();
| ResultSet rs = st.executeQuery("select * quest_chices");
|
| while(rs.next()) {
| out.println("<br> " + rs.getString("ID"));
| }
| rs.close();
| st.close();
|
| out.println("DONE");
| } catch (Exception e) {
| out.println("Exception thrown " + e );
| //e.printStackTrace();
| } finally {
| if (con != null) {
| con.close();
| }
| }
|
and guess what?? When I run the jsp file i got Exception thrown javax.naming.NameNotFoundException: MyDB not bound ...
What i noticed here, is that when I change my datasource other than DefaultDS, I'll get NameNotFoundException>>>>
Any help please??
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210420#4210420
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210420
More information about the jboss-user
mailing list