Comment on Tutorial - JSP Example to connect to MS SQL database and retrieve records By Abinaya



Comment Added by : sillee

Comment Added at : 2009-08-13 03:22:14

Comment on Tutorial : JSP Example to connect to MS SQL database and retrieve records By Abinaya
i'm a student and new to all these HTML and JSP.
i want to learn to do this Tomcat with Ms SQL where my Uni only provide us these resources. i've tried to copy the above codes and past to my Tomcat and tried to run, i can only get the junk text as below:
May i know what are the installation needed?
can any1 suggest on how to start from installing all the application to connecting them.
I'm using Windows based OS,
i got Ms SQL Server 2005 Studio Express installer,
i got Apache Tomcat 5.5.27 Server installer.
what are the necessary configuration needed to run these server application on my PC (i'm testing with my PC as server at the moment).

can any1 pls help~

<%@ page import="java.util.*" %> <%@ page import="javax.sql.*;" %> <% java.sql.Connection con; java.sql.Statement s; java.sql.ResultSet rs; java.sql.PreparedStatement pst; con=null; s=null; pst=null; rs=null; // Remember to change the next line with your own environment String url= "jdbc:jtds:sqlserver://research.utar.edu.my/ResearchPortal"; String id= "username"; String pass = "password"; try{ Class.forName("net.sourceforge.jtds.jdbc.Driver"); con = java.sql.DriverManager.getConnection(url, id, pass); }catch(ClassNotFoundException cnfex){ cnfex.printStackTrace(); } String sql = "select top 10 * from tbl_sys_user"; try{ s = con.createStatement(); rs = s.executeQuery(sql); %> <% while( rs.next() ){ %><% } %> <% } catch(Exception e){e.printStackTrace();} finally{ if(rs!=null) rs.close(); if(s!=null) s.close(); if(con!=null) con.close(); } %>
<%= rs.getString("cust_id") %> <%= rs.getString("rdate") %> <%= rs.getString("email") %>


View Tutorial



Subscribe to Tutorials

Related Tutorials

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Java program to check if user input is an even number

Archived Comments

1. good example tnq...........
View Tutorial          By: SaidiReddy at 2012-06-09 12:03:09

2. if done all the steps but i have found out this er
View Tutorial          By: hisham at 2010-11-24 11:01:54

3. introduction is very clear i get wat answer i want
View Tutorial          By: kalyan at 2013-07-02 09:23:40

4. Hi Dear All

How to do strike-out in

View Tutorial          By: Sandeep Mehta at 2012-11-21 06:54:06

5. Thanks for this nice comparision table for Spring
View Tutorial          By: guddu at 2009-10-17 03:08:59

6. After a great struggle I am able to successfully c
View Tutorial          By: raghu at 2012-01-04 15:10:07

7. article is good but I would have liked to get more
View Tutorial          By: Bharat Agrawal at 2010-09-25 22:18:40

8. gr8 work :)
View Tutorial          By: ahmad at 2011-03-23 01:05:57

9. Hi Ashley, thank you for this Android Gridview tut
View Tutorial          By: Giancarlo Leonio at 2013-03-12 00:37:15

10. Hello every one. I am working on my project in j2m
View Tutorial          By: Pradeep Reddy at 2011-01-04 05:15:51