File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 60774
    
  65

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: 60774
    
  65

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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using a session value on sql query
 
Similar Threads
Showing a list result in jsp view page from database
Try/Catch/Return
Data type mismatch need to convert string to a number
crating a table using JSP
Retrieving result from a result set