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

[394 byte] By [Eng.Mohammeda] at [2007-11-27 1:45:55]
# 1
why would your JSP ever be aware there was a database somewhere?
georgemca at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
> why would your JSP ever be aware there was a database> somewhere?because simply my application needs a DB , and i think DB is the main part of any system ,
Eng.Mohammeda at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Because being a presentation file (JSP), you shouldn't place any java code there. Look at mvc pattens.It is a good practice to split presentation from coding.MeTitusWhy dont you use EJB?Message was edited by: Me_Titus
Me_Titusa at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

Eng.Mohammeda at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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

appy77a at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
thanks a lot Appyu just put clearfy the picture to me
Eng.Mohammeda at 2007-7-12 1:06:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...