aspose file tools*
The moose likes JBoss/WildFly and the fly likes SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "SQLException" Watch "SQLException" New topic
Author

SQLException

Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
Hi All
I am testing datasource usage in JBoss with mysql database. I've created the configuration file, and run the client, but I got the following exception:

Exception thrown java.sql.SQLException: Table not found in statement [select * from quest_choices]

Table quest_choices exists and contains data, but I don't know why I got this error. I am using JBoss 5 and mysql 5.1.7, any help will be highly apprecieated...

Thanks
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Are you using the same schema to connect in application ?
Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
Yes, the same schema in mysql-ds.xml file and in the client...
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


I have not used mysql DB .. i understood its starts up in different sqlmode. check the link if this helps
Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
Thank you buddy for yr time, but I think it's not a sql mode problem. I defined the datasource to be available for JBoss, as any other database. then, I lookued up the datasource to get the connection for my database and schema.

I finished the above, and after running a simple sql statement against the database, I got SQLException stating that the table doesn't exist , I don't know why???
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Buddy ,

Better post your configuration xml and code to help better. Can you try to query DUAL table atleast to make sure the datasource configuration are correct and the problem is related to "table name and schema".
Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
I tried another table, it gave me the same results. One noticed thing is that connection is established, but when you try to run an sql statement against a given table, it will give you an error message stating that table don't exist......
Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
This is my mysql-ds.xml file:


and this is my jsp file which i used to try my datasource:


One thing, If I changed my datasouce name other than DefaultDS, I'll get a NamingException..

Any help pleeeeeeeease??
Javid Jamae
Author
Ranch Hand

Joined: May 14, 2008
Posts: 198
Did you remember to delete the default hsqldb-ds.xml file from your deploy directory?


Author: JBoss in Action, javidjamae.com, @javidjamae on Twitter
Jotnarta Jot
Greenhorn

Joined: May 18, 2006
Posts: 24
Yes I did, Is there any other configuration files that I must changed???
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Will the ; at the end of the Select statement work?( i hv nt tried anything like that) Even then i believe it throws Table or view does not exists
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

I thought Balu might have something there so I tried with and without the ';' at the end of the select - both worked.

But let me back up. I copied the code from your other code into one of my projects. Of course I changed the database and table name to match something I had. And everything worked. One caveat: I did not use server-side script in a JSP - instead I placed the code in a servlet and passed the resulting string to the JSP which accessed if via EL.

A few suggestions.

1) Do not call the datasource DefaultDS. Your other post that used MyDS is better.
2) Do not remove hsqldb-ds.xml - the DefaultDS is needed by several JBoss AS services. (You can replace it, but it takes some work. Ch15 of JBoss in Action provides the details)
3) Do what I did - put your code in a servlet, pass the string to the JSP and use EL. Not mandatory, but saner.

Here is a recap of everything you have to do, starting with a fresh install of JBoss AS 5.0.0.GA:

1) Copy the mysql JDBC JAR file to server/default/lib
2) Copy your mysql-ds.xml file to server/default/deploy
3) Copy your WAR file to server/default/deploy
4) Start the app server and access the JSP

Good luck.


JBoss In Action
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Peter,

The character ';' will not work in ORACLE driver implementations, hence the thought , anyways thanks for confirming.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: SQLException