aspose file tools
The moose likes JDBC and the fly likes Call SQL Script from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Call SQL Script from JSP" Watch "Call SQL Script from JSP" New topic
Author

Call SQL Script from JSP

Albert Hopkins
Greenhorn

Joined: Jul 21, 2007
Posts: 21
Hi...
I have a sql script called student.sql .

How can I call that script directly using JSP.

Example : Query = student.sql;

thanks

p.s : I hope I'm in the right topic.
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
I had a look at the JSTL sql tags and couldnt see anything how to do this. Possibly the reason is you shouldnt! Better not to have this sort of thing in JSP. I would recommend putting the database access in a business logic code i.e. a java class....


<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

Tom has it correct. A JSP is no place to be doing SQL access. Write this as a standalone Java class that you could trigger from a JSP if necessary, but do not perform database access in UI classes or JSPs.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

This post (along with many like it) inspired me to write a blog article about why adding JDBC to JSP is really bad: http://www.selikoff.net/blog/2009/02/24/why-jdbc-jsp-bad/

Hopefully, it helps explain the issue in detail.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Call SQL Script from JSP
 
Similar Threads
How to call a jsp from java script
how to call a php script from a jsp
How to call a cgi/perl script from jsp/java bean
SQL
calling functions in .js file