It would be of great help , if you please...elaborate more regarding the PreparedStatement Interface, and let me know the reason for including so many "+" operators..!!!
Even better... there's a professionally-written tutorial about JDBC, and it has a section about PreparedStatement. You can read it here: Lesson: JDBC Basics. Actually there's a lot of useful information in that tutorial, so it might be a good idea for you to work through the whole thing rather than just the PreparedStatement section.
It would be of great help , if you please...elaborate more regarding the PreparedStatement Interface, and let me know the reason for including so many "+" operators..!!!
Regards...
The "+" is nothing to do with JDBC, as it is simply used to concatenate strings together where you combine your literal SQL INSERT with the values in your variables to make one big SQL string. But this is the wrong way to do this anyway, as you should use bind variables here. Follow Paul's suggestion to find out more about using PreparedStatement and learning about JDBC.
ex-Oracle bloke
Abhimanyus singh
Greenhorn
Joined: Apr 11, 2012
Posts: 22
posted
0
Wendy Gibbons wrote:
Abhimanyus singh wrote:Hi ...Guys..
As I new to JDBC...and don't know how to insert records in the table through a JDBC program...
Somehow i managed to get a code for inserting records in the table.....
But, my concern is regarding the line....
I just need to understand that , what is the NEED of using too many '+' operators to embrace local variable "str" and "no" ???
regards.
are you actually asking why are there the 4 '+' signs in that statement?
I don't mean to be rude, but i think starting on jdbc may be a bit running before you can walk.
I am presuming this code is cut and pasted from someone else or somewhere else.
what the '+' signs are doing is adding strings together so
run this little snippet inside a main method
then look at that line in your code again, work out what it is doing.
Abhimanyus singh
Greenhorn
Joined: Apr 11, 2012
Posts: 22
posted
0
Wendy Gibbons wrote:I don't mean to be rude, but i think starting on jdbc may be a bit running before you can walk.
I am presuming this code is cut and pasted from someone else or somewhere else.
what the '+' signs are doing is adding strings together so
run this little snippet inside a main method
then look at that line in your code again, work out what it is doing.
Hi..Thank you a Lot!!! I can't believe that, something was being missed out by me!! Though, I knew that SQL accepts single quoted STRINGS, but LATER, I came to know that the TWO + operators ,embracing the string variable, are placed to prepend and append it with single quotes !!!