Java Mailing List Archive

http://www.junlu.com/

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

Re: JTDS help

Mario Winterer

2005-02-07

Replies:


I think the main time is spent on opening the database connection!
So you better use connection pooling - then this expensive operation is
just execute once (or at least not so often)
Have a look at the Tomcat documentation (Section on JNDI-DataSources)

Tex

Charles P. Killmer wrote:

>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://*.*.*.*:1433/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
>
>
>
>


---------------------------------------------------------------------
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.