Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: JTDS help

Mario Winterer

2005-02-07

Replies:

I do not think, jsp compilation is the problem - well, the first request
will last long, but after the jsp is compiled, subsequent calls will not
be remarkable slower than executing pure compiled servlet code.
(Charles, I hope you did not measure the time for the first request only
- which indeed includes compilation time, but for subsequent calls too).
So to me opening the connection is the major problem. Because the code
itself contains html-output, I think using jsp is quite ok.
The code would be much cleaner, if Charles used the JSTL tag-library:

<%@(protected)"%>
<%@(protected)" %>
<%@(protected)" %>
<sql:query sql="SELECT * FROM accounts" var="accounts"
dataSource=?jndi/myDataSource?/>
<table>
<c:forEach var="acc" items="${accounts}">
<tr>
<td><c:out value="${acc.ID}"/></td>
<td><c:out value="${acc.Name}"/></td>
</tr>
</c:forEach>
</table>

Best regards,
Tex

David Smith wrote:

> Ok. You're doing this in a jsp. That means Tomcat is:
>
> 1) Compiling your jsp to a servlet class.
> 2) Building a connection from scratch as opposed to picking up a
> pooled connection
> 3) Running the query.
>
> Of these, the first one is the most expensive operation followed by
> two. If you want fast, try
> doing this with a pooled connection and from compiled servlet code.
>
> --David
>
> Charles P. Killmer wrote:
>
>> Network results
>> Ping statistics for *.*.*.*:
>> Packets: Sent = 140, Received = 140, Lost = 0 (0% loss),
>> Approximate round trip times in milli-seconds:
>> Minimum = 0ms, Maximum = 0ms, Average = 0ms
>> Query Analyzer returns 85 rows in 0 seconds. I modified it to only
>> return Name and ID and it still runs slow. So it cant be row size,
>> network latency, hardware should be ruled out by the fact that it runs
>> super fast through query analyzer, and PHP and ASP.NET. Its only when I
>> write the code in JSP for Tomcat that it slows down.
>>
>> Charles
>>
>>
>> -----Original Message-----
>> From: Allistair Crossley [mailto:Allistair.Crossley@(protected):
>> Monday, February 07, 2005 11:37 AM
>> To: Tomcat Users List
>> Subject: RE: JTDS help
>>
>> Hi,
>>
>> There's no real reason relating to Tomcat or jTDS that this would run
>> slow. You are more likely to find answers with your hardware, network
>> latency, database load or row size and other environmental factors.
>>
>> Allistair.
>>
>>
>>
>>> -----Original Message-----
>>> From: Charles P. Killmer [mailto:charlesk@(protected)]
>>> Sent: 07 February 2005 17:34
>>> To: Tomcat Users List
>>> Subject: JTDS help
>>>
>>>
>>> I am trying to get Tomcat talking to my database quickly. This code
>>> takes about 2-3 seconds to load. Anyone got any idea's why? Or if you
>>> run this in your environment, how well does it run?
>>>
>>> <%@(protected).*"%>
>>> <%
>>> Connection conn =
>>> DriverManager.getConnection("jdbc:jtds:sqlserver://*.*.*.*:143
>>> 3/dbname;u
>>> ser=******;password=*******");
>>>
>>> Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
>>> ResultSet.CONCUR_READ_ONLY);
>>> ResultSet rs;
>>>
>>> rs = stmt.executeQuery("SELECT * FROM accounts");
>>>
>>> out.println("<table>");
>>> String name;
>>> String ID;
>>> while (rs.next()) {
>>> name = rs.getString("Name");
>>> ID = rs.getString("ID");
>>> out.println("<tr><td>" + ID + "</td><td>"+name+"</td></tr>" );
>>> }
>>>
>>> out.println( "</table>" );
>>>
>>> conn.close();
>>> %>
>>>
>>> This is just a JSP script, nothing is compiled. I know it is better to
>>> compile, but I am trying to chase down this DB slowness first.
>>>
>>> Charles Killmer
>>> Netgain Technology
>>> CharlesK@(protected)
>>> Office: (320) 251-4700 ext 107
>>>
>>>
>>>
>>
>>
>> <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE>
>> -------------------------------------------------------
>> QAS Ltd.
>> Developers of QuickAddress Software
>> <a href="http://www.qas.com">www.qas.com</a>
>> Registered in England: No 2582055
>> Registered in Australia: No 082 851 474
>> -------------------------------------------------------
>> </FONT>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
>> For additional commands, e-mail: tomcat-user-help@(protected)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
>> For additional commands, e-mail: tomcat-user-help@(protected)
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
> For additional commands, e-mail: tomcat-user-help@(protected)
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.