• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to execute PL/SQL block within JSP ?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to execute a block of PL/SQL statements (oracle) within JSP. The PL/SQL block will look like :

This is one simple un-labelled PL/SQL code block. How to execute this entire block within JSP using prepare statement etc ?
I cannot write stored procedure for this, as the actual PL/SQL block is different and is prepared dynamically.
Please help me.

Can I create stored procedures witin JSP ?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good grief... that's the LAST thing you want to be doing in a JSP.

Database access should not be happening in your presentation layer. Factor such processing into your model layer.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Furthermore, make the class to execute your SQL capable of being tested outside the servlet environment. When you know it is working, then you can wrestle with the complications of servlets and JSP.

Bill
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Furthermore, make the class to execute your SQL capable of being tested outside the servlet environment. When you know it is working, then you can wrestle with the complications of servlets and JSP.


I couldnt understand.
Do you mean writing a Java class that executes such PL/SQL block and call this java class within JSP ?
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

G Kiran Kumar wrote:I couldnt understand.
Do you mean writing a Java class that executes such PL/SQL block and call this java class within JSP ?



No. It would be better to write one or several java class(es) which take care of handling the SQL, then put the result (in a suitable form) into a scoped variable, and use the JSP only to display the result. You shouldn't do any database access from a JSP at all.
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for a way, without writing Java classes.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you only want to use JSPs - then you can do the same coding there as you can from inside a java class - but it is not the right way of doing it.

What you need is to use the JDBC API
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

G Kiran Kumar wrote:I am looking for a way, without writing Java classes.


Are you serious?

That's like trying to do surgery without a scalpel.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

G Kiran Kumar wrote:I am looking for a way, without writing Java classes.


Are you serious?

That's like trying to do surgery without a scalpel.



Indeed.

Please, for the sake of java, dont do it.

You can make your JSP only with a button, call a servlet(java class). That will be great for you and those who need to look to your code.

And, a JSP won't work without a webservice... so... go for it.

=D
 
G Kiran Kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic