JSP and Strored Procedures
hi
now i am analysing a new project , i will use JSP and BD2 , now the problem is that:
the database operations such insert delete and update , is it preferable to make them in methods in javaBeans or make a stored proceduers for them , if the stored procedurs are better than methods in javaBeans, how can we use stored procedures from jsp...
thats all ,
thanks
# 4
it seems that my point is not clear ...
i know that i have to separate my jsp and java code , this is not the point ,,
I need to know that the code that interactes with database to make my operatiosn like insert data and query, is it better to put this code inside a Java class "javaBean" and put my methods that make insert for example OR make a stored procedures in my DB and call it from any where "the jsp or a class" ,, if the stored procedues are better , how can we use it ...
EJB is another solutions, but it is out of my project's scope so i dicard it..
thanks a lot
# 5
> it seems that my point is not clear ...
> i know that i have to separate my jsp and java code ,
> this is not the point ,,
> I need to know that the code that interactes with
> database to make my operatiosn like insert data and
> query,
With stored procedures normally it is only possible to retrieve data, you can't use them to insert, update and delete records.
To insert, update and delete records use JDBC.
JDBC also could be used to retrieve records there is no problem in that.
Make use of Connection Pooling , PreparedStatements and RowSets for faster performance.
>is it better to put this code inside a Java
> class "javaBean" and put my methods that make insert
> for example OR make a stored procedures in my DB and
> call it from any where "the jsp or a class" ,, if the
> stored procedues are better , how can we use it ...
Do you have a very complicate database query? Are there too many joins, is the resultset obtained from a sequence of steps, then stored procs could be considered here.
Stored procs are like mini programs , Goolge "Stored Procedures" to learn more about them.
Also Stored Procedures are specific to the database you are using, what database are you using?
For example there are Oracle Stored Procedures, MySQL Stored Procedures etc.
The stored procedures syntax is specific to the database you use.
When you call a stored procedure it returns a ResultSet, stored procedures can be called from JDBC code which then stores result sets.
> EJB is another solutions, but it is out of my
> project's scope so i dicard it..
> thanks a lot