| | |
JDBC problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2007
Posts: 28
Reputation:
Solved Threads: 0
HI
I m using excel as a database..
In my DB i m having fields name and some value assigned to each name..
Now on my jsp page i m generating an array of names by some processing..
Now what i want is to access the names from the DB which r nor present in the array that i've generated. Want to get names and values other than array names..
how can i do this..
plz reply.
thanks
I m using excel as a database..
In my DB i m having fields name and some value assigned to each name..
Now on my jsp page i m generating an array of names by some processing..
Now what i want is to access the names from the DB which r nor present in the array that i've generated. Want to get names and values other than array names..
how can i do this..
plz reply.
thanks
It might help if you showed your code (and hopefully the DB stuff is in a bean and is not a scriptlet in your jsp), and then trying to better explain what it is you want, because I'm not at all sure of what it is you're asking here.
Also, use code tags when you post your code.
Also, use code tags when you post your code.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Excel is no database.
Using JDBC to access Excel is BAD.
Using JDBC from JSP is BAD.
So it seems like you'd best completely scrap whatever you have already and start from scratch with some research into proper application architecture.
Using JDBC to access Excel is BAD.
Using JDBC from JSP is BAD.
So it seems like you'd best completely scrap whatever you have already and start from scratch with some research into proper application architecture.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
NO, you do NOT use Excel as a database.
That's already been established firmly.
Excel is NOT a database.
Just because you can create ODBC DSNs to Excel files doesn't mean you should use those DSNs as database aliasses.
That's already been established firmly.
Excel is NOT a database.
Just because you can create ODBC DSNs to Excel files doesn't mean you should use those DSNs as database aliasses.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Dec 2007
Posts: 28
Reputation:
Solved Threads: 0
Hi all
thanks for all reply..
i just want to know how to compare a field in a database with the array..
means suppose i've array of names and i want to access those names from the database other than the array that i've.
i m using--
here actually i want to compare FirstName with total my_arr..
Means get HR whose FirstName is not equals to all names in my_arr.
As per i m using it'll compare only one name at a time,but i want to compare with array..
how it is possible??
plz reply..
thanks..
thanks for all reply..
i just want to know how to compare a field in a database with the array..
means suppose i've array of names and i want to access those names from the database other than the array that i've.
i m using--
Java Syntax (Toggle Plain Text)
for(int i=0;i<my_arr.length;i++) { query = "select * from my_table where HR=(select max(HR) from my_table where FirstName <>'"+my_arr[l]+ "' )"; }
here actually i want to compare FirstName with total my_arr..
Means get HR whose FirstName is not equals to all names in my_arr.
As per i m using it'll compare only one name at a time,but i want to compare with array..
how it is possible??
plz reply..
thanks..
First, as the others have said, Excel is not a DB, and you shouldn't be using it as such.
Second of all, this is an SQL question, not a Java/JSP/JDBC question. Next time, find an SQL forum.
not
Edit: This should, at least, be a valid SQL now. Whether it gives you what you want is another question.
Second of all, this is an SQL question, not a Java/JSP/JDBC question. Next time, find an SQL forum.
Java Syntax (Toggle Plain Text)
.... where HR IN ( ....
Java Syntax (Toggle Plain Text)
.... where HR = ( ....
Edit: This should, at least, be a valid SQL now. Whether it gives you what you want is another question.
Last edited by masijade; Mar 21st, 2008 at 2:10 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Mar 2008
Posts: 4
Reputation:
Solved Threads: 0
Hi ABhi,
Try Like this...
Try Like this...
java Syntax (Toggle Plain Text)
String hrname="("; for(int k=0;k<my_arr.length;k++) { hrname+="'"+my_arr[k]+"',"; } hrname+=")"; for(int i=0;i<my_arr.length;i++) { query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")"; }
Last edited by WolfPack; Mar 22nd, 2008 at 2:49 am. Reason: Added code tags. Use them the next time you post code.
•
•
•
•
Hi ABhi,
Try Like this...
java Syntax (Toggle Plain Text)
String hrname="("; for(int k=0;k<my_arr.length;k++) { hrname+="'"+my_arr[k]+"',"; } hrname+=")"; for(int i=0;i<my_arr.length;i++) { query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")"; }
To start with:the first for-loop will end with the command: hrname+="'"+my_arr[k]+"',";
Meaning that after the loop the command: hrname+=")"; will generate this String:
hrname = " ...... ',) " . As you can see the comma before the parenthesis will generate an sql error.
The second for-loop is completely unnecessary. You don't use the index i, and you simply assign to the variable query the same String over and over again.
I think that you don't need the loop and only the assignment:
Java Syntax (Toggle Plain Text)
String query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")";
Last edited by javaAddict; Mar 22nd, 2008 at 7:52 am.
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- jdbc problem (Java)
- Problem connecting my Tomcat Server and MySQL using JSP (JSP)
- problem in installing jdbc... (Java)
- Problem with Java Swing (Java)
- JDBC for Access Database (Java)
- Java JDBC ResultSet (Java)
- Ms Access sql problem (Java)
Other Threads in the Java Forum
- Previous Thread: Absolute value of a "double" variable?
- Next Thread: question about compiling
| Thread Tools | Search this Thread |
Tag cloud for Java
@param add android api apple applet application arguments array arrays automation bank binary binarytree bluetooth bold chat chatprogramusingobjects class classes client code compare component coordinates database digit draw eclipse editor error event exception fractal game givemetehcodez graphics gui guidancer health html ide image input int integer integration j2me jarfile java javac javame javaprojects jmf jni jpanel julia keytool learningresources linux list loop map method methods mobile netbeans newbie nonstatic number oracle pattern print problem program programming project projectideas recursion scanner screen server set sharepoint size sms socket sort sorting sql sqlserver string swing test text-file threads time tree web windows






