aman0711
asked on
Java SQL execute Update
hi all,
I have a little confusion in a answering an objective question, I can across in a test regarding executeUpdate.
according to API, executeUpdate returns either a 0 or the row count...
But in the possible options, I am not seeing status code 0 at all.
I have a little confusion in a answering an objective question, I can across in a test regarding executeUpdate.
according to API, executeUpdate returns either a 0 or the row count...
But in the possible options, I am not seeing status code 0 at all.
i am not sure what do you mean by possible option. But executeUpdate will return 0 if no records are upated with your query stmt. If there are any records that are updated will give count of records that are updated.
hi aman,
what options are there?
executeUpdate public int executeUpdate(String sql)
throws SQLException Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
Parameters:sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing Returns:either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing Throws: SQLException - if a database access error occurs or the given SQL statement produces a ResultSet object
what options are there?
executeUpdate public int executeUpdate(String sql)
throws SQLException Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
Parameters:sql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing Returns:either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing Throws: SQLException - if a database access error occurs or the given SQL statement produces a ResultSet object
ASKER
Hey Kadaba, arevuri,
Thanks for the reply :)
Here are the options:
Thanks for the reply :)
Here are the options:
executeUpdate should be used when a SQL does not return results.
what value does executeUpdate return?
Choice 1
A result set with one entry specifying the number of altered rows
Choice 2
The number of rows altered
Choice 3
The size of the result set
Choice 4
An integer status code indicating the success or failure of the SQL statement
Choice 5
The number of rows in the altered table
ASKER
I guess choice 4 in this scenario?
Choice 2
The number of rows altered
The number of rows altered
ASKER
Hi Kadaba,
I am confused here, in the top statement its said that statement isnt returning any results. so which means a status code of 0. isnt it?
I have another question for you, which I cant find answer for :)
I am confused here, in the top statement its said that statement isnt returning any results. so which means a status code of 0. isnt it?
I have another question for you, which I cant find answer for :)
Choice 1
A result set with one entry specifying the number of altered rows -- throws SQL exception if it does
Choice 2
The number of rows altered -- true
Choice 3
The size of the result set -- not applicable
Choice 4
An integer status code indicating the success or failure of the SQL statement -- the success itself is governed by return code 0 if DDL statement else no of rows altered if DML statements
Choice 5
The number of rows in the altered table - if an alter table query is executed then return code would be 0.
the options me too :P, wait for arevuri's or anyone else's view :)
A result set with one entry specifying the number of altered rows -- throws SQL exception if it does
Choice 2
The number of rows altered -- true
Choice 3
The size of the result set -- not applicable
Choice 4
An integer status code indicating the success or failure of the SQL statement -- the success itself is governed by return code 0 if DDL statement else no of rows altered if DML statements
Choice 5
The number of rows in the altered table - if an alter table query is executed then return code would be 0.
the options me too :P, wait for arevuri's or anyone else's view :)
ASKER
hehe no worries :-)
Ok heres another tricky one :)
What Java technology do you use in JSP to map HttpRequest parameters to properties in JavaBeans?
Ok heres another tricky one :)
What Java technology do you use in JSP to map HttpRequest parameters to properties in JavaBeans?
ASKER
Kadaba,
Check your email :)
Check your email :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For other questin on http parameters, use servlets or JSP to read values using http request bject parameter values and assign them to your java beans or try custom tag libs technology
ASKER
Hey arevuri, let me show u the options for second one
ASKER
Here are the options for 2nd question:
Reflection and inheritance, JSP Container, Polymorphism, Introspection and reflection,
JNI
Reflection and inheritance, JSP Container, Polymorphism, Introspection and reflection,
JNI
reflections are vey costly in terms of performance
ASKER
So what would be the option for this arevuri?
you do not need any new technology for this. You can directly get values of http parameters using implicit objects of JSP (like request.getParameter("")) and set it to your bean. If your page is dynamic, you do not know the param names and want to create new java bean classes dynamically, then reflections are only the way
ASKER
Thanks arevuri,
so I guess I will pick:
Introspection and reflection
so I guess I will pick:
Introspection and reflection
ASKER
Thanks folks :)