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



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 above code is not for storing values it return
View Tutorial          By: vinoj at 2010-04-28 15:58:47

2. I am getting error in setContentView(R.layout.main
View Tutorial          By: user at 2012-01-13 06:49:42

3. Hi,
I have loaded all 5 java classes and i

View Tutorial          By: DurgaPrasad at 2011-11-24 06:02:19

4. Which one is the inbuilt Abstract class in java
View Tutorial          By: vikas jain at 2013-04-16 07:25:33

5. This is very good article.
View Tutorial          By: Vipin Joshi at 2008-03-27 13:53:26

6. Highly appreciatable.Excellent Docs.
View Tutorial          By: Debi P Naik at 2010-05-04 05:55:45

7. Rattling explanation .....thnx brother
View Tutorial          By: zorro at 2011-06-16 05:05:43

8. You have to run the compiled PortScanner with two
View Tutorial          By: KRook at 2009-10-15 04:11:53

9. Hi ,

Is there any way to export con

View Tutorial          By: Nithya Duraiswamy at 2009-03-03 21:32:05

10. There is 3rd Party webservices hosted over HTTPS,
View Tutorial          By: Ankur at 2012-02-24 16:49:59