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



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

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

Archived Comments

1. The SAX Parser code has a problem for files of gre
View Tutorial          By: Mark Nelson at 2011-11-14 20:16:41

2. Thanks a ton! :)
View Tutorial          By: Prateek at 2015-03-12 11:40:08

3. To execute program you need comm.jar that is not a
View Tutorial          By: shreyansh shah at 2012-07-11 05:57:42

4. Excellent Example to explain the functions
View Tutorial          By: manish at 2010-08-05 03:10:43

5. thank u very much......... its very helpful
View Tutorial          By: ankit at 2012-10-14 20:52:24

6. Very good. Keep it up.
View Tutorial          By: jk at 2009-05-23 11:00:29

7. hey plzz help me the code is not working for me...
View Tutorial          By: kuldeep at 2014-02-24 18:16:59

8. you have extended class Abc within class Abc

View Tutorial          By: SUNIL SHAH at 2012-05-25 06:17:23

9. Good Explanation.
View Tutorial          By: Ashishkumar Haldar at 2013-01-03 11:47:25

10. A good short article on Struts. Require a step by
View Tutorial          By: Atul Saxena at 2012-01-09 19:56:59