Im trying to access the databsae values & displaying it on the screen..my database connections r alright & evn the db is also rite..but its not displayin anything on the screen..can u help me??

<html>
<head><Title> login details </title><head>

<%@page language="java" import="java.io.*,java.sql.*"  %>

<body>
<% 
	String name="";
	String pass="";
	try
	{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con=DriverManager.getConnection("jdbc:Odbc:mydsn");
		Statement st=con.createStatement();
		ResultSet rs=st.executeQuery("select * from notice");
		while(rs.next())
		{
			name=rs.getString(1);
			out.write(name);	
		pass=rs.getString(2);
out.write(pass);
		}
	}catch(Exception e){System.out.println(e); }
	System.out.println("name");
//	out.write();
	out.write(pass);
%>

</body>
</html>

Recommended Answers

All 5 Replies

Beside you not using [code]

[/code], there is obviously your attempt to connect to DB from JSP instead from servlet/bean and wrong coding for DB connectivity. Read tutorial on JDBC Access for basic background

and then there's the use of the JDBC/ODBC bridge driver which is also a recipe for disaster.
And the bad "Title" tag in the html (browsers won't generally complain, but it's not correct).

ok but can u tel me which wil be then rite code??

just send me the rite code if possible

Read the tutorial to which I provided link.

and no, we're not going to do your homework for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.