Topic
  • 3 replies
  • Latest Post - ‏2010-01-04T21:28:13Z by DGawron
myredbox
myredbox
2 Posts

Pinned topic Error in fetching data in MySQL

‏2009-12-27T09:55:32Z |
i am trying to build my first application about accessing MySQL and retrieving data. But it fails.
i already established a database pool in WASCE. And the pool points to database "sample".
I tried to run SQL("select id,name from employee") in WASCE console, it successed.
I also followed the action in "usage" of WASCE console and configure some references in the web.xml, geronimo-web.xml in order to refer to the datasource.

i created "Database Service Provider" model in WPF, and use the pop down option "java:comp/env/jdbc/MyDataSource" as DataSouce.(The opt is pop down by WPF automatically)
i add SQL "Select id,name from EMPLOYEE"
But it alert an error message. I checked the log. It reports that "java.sql.SQLException: Table/View 'EMPLOYEE' does not exist."
Certainly, the table "EMPLOYEE" exist in database.
And i tried to modify SQL for adding database name in front of table name "Select id,name from sample.EMPLOYEE"
It alert "java.sql.SQLException: Schema 'SAMPLE' does not exist".

Do you have any idea or suggestion?
Thank you.
Updated on 2010-01-04T21:28:13Z at 2010-01-04T21:28:13Z by DGawron
  • myredbox
    myredbox
    2 Posts

    Re: Error in fetching data in MySQL

    ‏2009-12-27T10:01:09Z  
    I also supply some key information as belw:

    1. I add reference content in WEB-INF/web.xml:
    <resource-ref>
    <res-ref-name>jdbc/MyDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

    2. I modified "WEB-INF/geronimo-web.xml" as below,

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app
    xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
    <environment>
    <moduleId>
    <artifactId>MyWebApp</artifactId>
    </moduleId>
    <dependencies>
    <dependency>
    <groupId>console.dbpool</groupId>
    <artifactId>MySQLPool</artifactId>
    </dependency>
    </dependencies>
    </environment>

    <context-root>/MyWebApp</context-root>

    <!-- security settings, if any, go here -->

    <resource-ref>
    <ref-name>jdbc/MyDataSource</ref-name>
    <resource-link>MySQLPool</resource-link>
    </resource-ref>
    </web-app>
  • DGawron
    DGawron
    251 Posts

    Re: Error in fetching data in MySQL

    ‏2010-01-04T21:09:11Z  
    Try using the Database Explorer section of the SQL Call builder to generate the select for you. If SQL Call can see the MySQL datasource, then it will be able to generate a sample select statement for you.
  • DGawron
    DGawron
    251 Posts

    Re: Error in fetching data in MySQL

    ‏2010-01-04T21:28:13Z  
    One more thing. MySQL isn't an officially supported database. If you are planning to use MySQL for a production deployment with WPF, then you may want to take that into account. The WPF release notes (http://www.ibm.com/developerworks/websphere/zones/portal/portletfactory/proddoc.html) list the supported databases for each release. If you decide to use MySQL, then we'll only be able to offer best-effort support if you run into any problems.