Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JBOSS EntityBean CMP with MySQL Help

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have setup JBoss-IDE with Eclipse with Jboss. The Jboss Version I use jboss-4.0.2RC1.

1. I have configured MySQL version 5.0.21 to Jboss. and I followed the URL
http://www.cotsec.com/documentation/installation/j2ee_jboss_mysql/index.html#3.%20Add%20the%20Java%20MySQL%20Library
to configure the database with JBoss.


2. I made a small table with MySQL

CREATE TABLE `fortunedb`.`test` (
`id` varchar(10) NOT NULL,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


3. I made a simple Entity Bean Call Test bean to connect to the test table as follow

ejb-jar.xml::::

<![CDATA[Description for Test]]>
<display-name>Name for Test</display-name>

<ejb-name>Test</ejb-name>

com.account.TestHome
com.account.Test

<ejb-class>com.account.TestCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
False

<cmp-version>2.x</cmp-version>
<abstract-schema-name>Test</abstract-schema-name>
<cmp-field >
<![CDATA[]]>
<field-name>id</field-name>
</cmp-field>
<cmp-field >
<![CDATA[]]>
<field-name>name</field-name>
</cmp-field>
jboss.xml::::::

<ejb-name>Test</ejb-name>
<jndi-name>ejb/Test</jndi-name>



jbosscmp-jdbc.xml::::


java:/MySqlDS
<datasource-mapping>mySQL</datasource-mapping>


<enterprise-beans>

<ejb-name>Test</ejb-name>
<table-name>test</table-name>

<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>

</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>name</column-name>
</cmp-field>

</enterprise-beans>


4. I am running a Servlet Client to get the connection

public void init(ServletConfig config) throws ServletException {
try {
Context context = new InitialContext();
Object ref = context.lookup("java:comp/env/ejb/Test");
home = (TestHome) PortableRemoteObject.narrow(ref, TestHome.class);
} catch (Exception e) {
throw new ServletException("Lookup of java:/comp/env/ failed" + e);
}
}

protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException {

resp.setContentType("text/html");
PrintWriter out=resp.getWriter();


try {

Test bean = home.findByPrimaryKey("jk");
out.print(bean.getName());
} catch (Exception e) {
out.print(e);
}


5. But when I run this Servlet it gives me the following error

"javax.ejb.FinderException: Find failed: java.sql.SQLException: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM test t0_Test WHERE' at line 1""

Please help me to go further on this. I am totally stuck here and I coukld not realise where I made the mistake.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Same problem with me too
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sam, please do not resurrect 3 year old posts, but instead [url=]tell the details[/url] in a new post. For example, do you really have a table called 'fortunedb' located in database 'test'? (That is a horrible table name, by the way, and I would never put anything into the 'test' database.)
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic