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



Comment Added by : Harshal

Comment Added at : 2013-02-19 14:56:35

Comment on Tutorial : JSP Example to connect to MS SQL database and retrieve records By Abinaya
I am getting a blank page. Closed the table tag and added the headers. Below is the modified code. Please let me know what is the issue with this?

<html>
<head><title>Enter to database</title></head>
<body>
<table border="5">
<%@ 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://harshal:1433/jasptest";
String id= "sa";
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 * from tbl_sys_user";
String sql = "select top 10 * from tbl_sys_user";
try{
s = con.createStatement();
rs = s.executeQuery(sql);
%>

<%
while( rs.next() ){
%>


<tr>
<th>Header 1
<td><%= rs.getString("cust_id") %></td>
</th>
</tr>

<tr>
<th> Header 2
<td><%= rs.getString("rdate") %></td>
<th>
</tr>

<tr>
<th>
<td><%= rs.getString("email") %></td>
</th>
</tr>
<%
}
%>

<%

}
catch(Exception e){e.printStackTrace();}
finally{
if(rs!=null) rs.close();
if(s!=null) s.close();
if(con!=null) con.close();
}

%>
</table>
</body>
</html>


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. my question is the same of sajjad.what about (!iss
View Tutorial          By: hossain at 2012-04-26 04:28:56

2. sir i need some simple example of jdbc i cannot un
View Tutorial          By: Velkumar.s at 2013-05-15 07:08:37

3. Nice one really helpful thanks
View Tutorial          By: Shashikant at 2012-01-06 12:00:45

4. FilenameFilter only = new OnlyExt("html"
View Tutorial          By: joyes at 2009-08-25 11:34:13

5. realy very nice artical it give good understable
View Tutorial          By: vivek at 2009-06-19 01:27:46

6. Hey guys, can u help me out over here..
thi

View Tutorial          By: Ridge Fernandes at 2012-01-19 04:09:45

7. how to solve this problem

javax.com

View Tutorial          By: rajani at 2009-07-18 05:44:55

8. Can anybody send me the java full code for sending
View Tutorial          By: David at 2010-08-22 22:57:38

9. Hats off man !!! Very Simple & Straightforward
View Tutorial          By: Nitesh at 2013-01-06 00:50:53

10. precisely the drawbacks I am trying to address in
View Tutorial          By: ernest at 2011-02-05 02:16:13