|
-
Apr 21st, 2006, 10:38 AM
#1
-
Apr 21st, 2006, 05:06 PM
#2
Frenzied Member
Re: How to Write SQL statements in Java Programs
I'm not sure I understand your question(I'm not an SQL geek though )
But AFAIK, SQL is to be written as a string and then passed to a method, in which case you wouldn't need a specific type for the variables themselves, it'd all be a matter of following the SQL syntax.
Correct me if I'm wrong? =).
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Apr 21st, 2006, 05:40 PM
#3
Re: How to Write SQL statements in Java Programs
I agree
and for the second part, SQL statement delimiters are the same for both languages
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Apr 21st, 2006, 05:46 PM
#4
Re: How to Write SQL statements in Java Programs
The pound sign (#) is only used in MSAccess as a date deliminater. The rest of them ususally just use a single qoute around a valid date format
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 26th, 2006, 11:49 AM
#5
Re: How to Write SQL statements in Java Programs
Hi guys,,,
Thanks for the tips...Yup, I was referring to the sql statement being copied to a string variable..I used the single quotation in this sql statement and it did work...
Here is the sample code:
Code:
String sql = "INSERT INTO DeptSelection (DeptDescription,DeptID, DeptAddress1,DeptAddress2,DeptCity,DeptPostalCode) " +
"VALUES('"+getDeptDescription()+ "', "+getDeptTypeId()+", '"+ getDeptAddress1()+ "',
'" +getDeptAddress2()+ "','"+getDeptCity()+"','"+getDeptPostalCode()+"')";
How come java uses the symbol + in the getMethods.I just code the idea from a book?
Greg
-
Apr 26th, 2006, 01:11 PM
#6
Re: How to Write SQL statements in Java Programs
+ sign is used for String concatenation
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|