aspose file tools*
The moose likes JDBC and the fly likes using a session value on sql query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "using a session value on sql query" Watch "using a session value on sql query" New topic
Author

using a session value on sql query

Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
I am getting a value from a drop down menu and storing it in the sessions bean. However when I try to get that value to use it on a query i am getting an error. That value is the DB that i am going to use for my query...

these are my values...what am i doing wrong?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Eduardo Ponce de Leon wrote: i am getting an error.

Keeping the error a secret isn't going to help us help you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
The erros is saying that the DB does not exist...and its true the database "db" is not the name of my databes, my problem is that i dont know how to set the value of the stored value of my bean in the sql query.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Sigh. Show the entire error message.
Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
ok...so this is my query...

SELECT
"JUN_F1"."Renta"
FROM
public."JUN_F1"
WHERE
"JUN_F1"."Telefono" = '9717029902';

JUN_F1 is the name of my table but that name, however this name is formed by JUN (variable) and _F1 (text)...I cant write my query to store in a string variable to do what i need to do, the problem is the quotes..basically my query will look like this...



remember... month is the value stored in another variable and _F1 is plain text
This is what i want to do..

String query = "SELECT "month+_F1"."Renta" FROM public."month+_F1" WHERE "month+_F1"."Telefono" = '9717029902';";

any help with the quotes!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using a session value on sql query