Yes, you can use stored procedures. There are a few ways you could go about
it; see http://java.sun.com/j2se/1.3/docs/api/index.html, look at the
java.sql and javax.sql API docs, and see http://java.sun.com/products/jdbc/
for a product page. These URLs contain quite a bit of information that can
help you.

You might also want to look into the use of EJBs rather than accessing the
database directly yourself; this kind of tight coupling eventually kills
performance.

(If you have more scriptlet code than you do HTML/JSP tags, that's probably
a sign that you need to use tag libraries or a servlet instead. This kind of
approach - "How do I access a DB in JSP?" - tends to create just that
scenario. While convenient, it's not very efficient, and we all like good
performance, right? .. Right?)


>From: Willy LEGIMAN <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: JSP accessing db stored procedures
>Date: Thu, 8 Feb 2001 12:56:25 +1100
>
>Hi there,
>
>I have seen many examples of JSP accessing the database using JDBC. In all
>these cases, the resultset is achieved via "direct" execution of the SQL
>statement.
>E.g. ResultSet rSet = stmt.executeQuery("insert into tblColor ....");
>E.g. ResultSet rSet = stmt.executeQuery("call insertColor....");
>
>Is it possible to access stored procedures via a server command object? I
>have an existing code in ASP which I'm going to rewrite in JSP. It calls
>stored procedure 'insertColor' and passes the data parameters to it without
>having to worry about the SQL statement as in the above example.
>--
><%
>' This whole chunk to be converted to JSP or jBeans...
>dim rs
>dim oCmd
>
>' Get database connection...
>
>Set oCmd = Server.CreateObject("ADODB.Command")
>With oCmd
>         .ActiveConnection = dbconn
>         .CommandText = "insertColor"
>         .CommandType = adCmdStoredProc
>         .Parameters.Append
>.CreateParameter(,adChar,adParamInput,len(colorCode),colorCode)
>         .Parameters.Append
>.CreateParameter(,adChar,adParamInput,len(colorDesc),colorDesc)
>         .Parameters.Append
>.CreateParameter(,adChar,adParamInput,len(colorStyle),colorStyle)
>End With
>
>set rs = oCmd.Execute
>
>%>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to