You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hari Saptoadi <ha...@indonesian-aerospace.com> on 2005/02/06 02:44:11 UTC

Re: JTDS help

i think using JDBC data source would be better solution for your problem ,
so the con pooling maintenance by the container
and you don't have to worry about the risk....CMIIW

----- Original Message -----
From: "Charles P. Killmer" <ch...@netgaintechnology.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, February 08, 2005 5:41 AM
Subject: RE: JTDS help


> When I strip the code to simply this,
>
> <%@ page language="java" import="java.sql.*"%>
> <%
> Connection conn =
> DriverManager.getConnection("jdbc:jtds:sqlserver://*.*.*.*:1433/dbname;u
> ser=*****;password=******");
> conn.close();
> %>
>
> It still runs slowly.  And yes it is multiple refreshes.
>
> I have tried to use connection pooling but have not been able to get it
> working yet.  Also the thing that I run into with connection pooling the
> inability to use the SQL Statement of "select @@IDENTITY from table".
> With connection pooling, you run the risk of getting the ID for a record
> that someone else inserted with the same connection.
>
> If connection pooling is the only option, I can work around that issue.
> But it seems that if PHP, ASP, ASP.NET... Can access the database just
> fine without connection pooling, JSP should be able to as well.
>
> Any thoughts?
> Thanks for all your input.
> Charles
>
> -----Original Message-----
> From: Mario Winterer [mailto:mario.winterer@eduhi.at]
> Sent: Monday, February 07, 2005 2:43 PM
> To: Tomcat Users List
> Subject: Re: JTDS help
>
> 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:
>
> <%@ page language="java"%>
> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib
> prefix="sql" uri="http://java.sun.com/jstl/sql" %> <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@QAS.com] Sent:
> >> 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@netgaintechnology.com]
> >>> 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?
> >>>
> >>> <%@ page language="java" import="java.sql.*"%> <% 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@NetgainTechnology.com
> >>> 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@jakarta.apache.org
> >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org