--- David Jencks <[EMAIL PROTECTED]> wrote: > Hi,
> I misunderstood, I thought you wanted to just define
> the query in jaws.xml.
Naah, I've decided to do it the hard way .... :-)
> If this won't work,
> maybe you should show your code and indicate where
> the exception happens.
OK, here's the method ....
-----------------------------------------------------------------------------------------------------
public Collection ejbFindByCategory(String category)
{
Connection conn = null;
Vector articles = new Vector();
try
{
InitialContext jndiContext = Helper.getInitialContext();
DataSource home_data = (DataSource)
jndiContext.lookup("java:/mySQLDS");
conn = home_data.getConnection();
Statement statement = conn.createStatement();
String query = "SELECT ArticleID FROM articles " +
"WHERE
articles.ArticleID=articles_to_categories.ArticleID " +
"AND
articles_to_categories.ArticleCategoryID=article_categories.ArticleCategoryID
" +
"AND article_categories.ArticleCategory='"+
category + "'";
ResultSet rs = statement.executeQuery(query);
ArticleHome home = (ArticleHome)ctx.getEJBHome();
while (rs.next())
{
// Now retrieve the entity
articles.addElement(new Integer(rs.getInt("ArticleID")));
}
}
catch (NamingException e)
{
System.out.println("Naming error --> " + e.getMessage());
}
catch (SQLException e)
{
System.out.println("SQL error --> " + e.getMessage());
}
finally
{
try
{
conn.close();
}
catch (SQLException e) {}
}
return (Collection)articles;
}
---------------------------------------------------------------------------------
The exception I get back is:
------------------------------------------------------------------------------------
[Article] SQL error --> Error during query: Unexpected Exception:
java.sql.SQLEx
ception message given: General error: Unknown table 'articles_to_categories' in
where clause
------------------------------------------------------------------------------------
And 'articles_to_categories' exists, altough I have not defined an entity
for it (there is an entity for 'articles', which doesn't thrown an exception.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user