aspose file tools
The moose likes JDBC and the fly likes can't run query from java war Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "can Watch "can New topic
Author

can't run query from java war

moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
Hi, I developed a jar file which turn to the h2 db and reads data.
I included this jar inside a web application that I developed using
eclipse.
I have a jsp file that reads data from the db using that jar. It works
fine in the eclipsa.
When I exectute war file out of that web app, and put it into the
webapps in tomcat server,
and run the application, I get an exception says that the db table I
try to read from is not exsisted:
"Table SYSTEMPARAMETERS not found".
This table is exsisted, and the fact that I can read from it using
that application in eclipse environment proofs it.

any idea?
thanks
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 779

Hi Moshi, I too faced the problem in the beginning, the problem is you have to mention the database name in the query,

select * from my_table; this will work well from eclipse.

But when you deploy you must write the query like this

select * from my_database.my_table; this will work, once try this.

Have a nice day.


Love all, trust a few, do wrong to none.
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
Hi Anusha, thanks for your reply.
My DB name is "test" , so I added it like this: select sysname, systemvalue from test.systemparameters
But unfortunately I get the error: "Schema TEST not found".
I realy don't know what to do...
If you have any other idea I'll be more then happy to here.
Thanks , Moshi.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 779

moshi cochem wrote:Hi Anusha, thanks for your reply.
My DB name is "test" , so I added it like this: select sysname, systemvalue from test.systemparameters
But unfortunately I get the error: "Schema TEST not found".
I realy don't know what to do...
If you have any other idea I'll be more then happy to here.
Thanks , Moshi.


systemparameters table belongs to another schema, I think you are using oracle, am I correct. systemparameters belongs to the database provided schema, try to use it from that, not from your test database, if you want to do so, test database must contain that table created in it.

Have a nice day.
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
systemparameters is the name that I gave to my table. it is like any other table...
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
And more than this:
when the db is opened, i can't use it from any other program - i get "db is already opened", and it's fine.
the problem is when the db is opened and i run my web app, i get exception of " table not exsist" and nothing about "db is already in use".
this issue, and the fact that he doesn't find my tables / db, makes me fill like he turn to another db from the web app.
But what (if so) is this additional db ?
thanks.
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 177
Hi,
Did you check the datasource used by the Tomcat server is using test schema?
Thanks
Sudha
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
you mean that if it weren't test , but another name of db, there is a chance that the tomcat would run it fine ?
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 177
Hi
In JDBC, if you retrieving the connection from the datasource then make sure the datasource has the schema name as test.
Or If you are not using datasource, then while retrieving the connection(DriverManager.getConnection(.....)), check whether you are using the right schema name i.e. test.
Thanks
Sudha
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 779

moshi cochem wrote:you mean that if it weren't test , but another name of db, there is a chance that the tomcat would run it fine ?


Yes.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: can't run query from java war
 
Similar Threads
Struts And Weblogic
JDBC connection in Oracle Application Server 10g
how we can create database connection dynamically.
H2 database consule lockings
WS with app that uses Ant Build