<%@ page language="java" contentType="text/html" %> <%@ page import="javax.servlet.*" %> <%@ page import="javax.servlet.http.*" %> <%@ page import="java.sql.*, java.io.*, java.util.*" %> <% Connection conn = null; ResultSet rs=null,rs1=null; String a=null,b=null; try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (Exception E) { out.println("Unable to load driver."); E.printStackTrace(new PrintWriter(out)); } try { conn = DriverManager.getConnection("jdbc:mysql://localhost/uttarbanga_net_-_uttar","uttarb","BaUaN12"); } catch (SQLException E) { out.println("SQLException: " + E.getMessage()); out.println("SQLState: " + E.getSQLState()); out.println("VendorError: " + E.getErrorCode()); } %> uttarbanga.net
<% try { java.sql.Statement stmt = conn.createStatement(); java.sql.Statement stmt1 = conn.createStatement(); rs1=stmt.executeQuery("select * from login"); while(rs1.next()) { a=rs1.getString("username"); b=rs1.getString("designation"); rs=stmt1.executeQuery("select * from news where username='"+a+"' and designation='"+b+"'"); out.println(""); out.println(" "+b); out.println(""); out.println("
"); while(rs.next()) { out.println(rs.getString("new_field")); } out.println("
"); } %>
Job Section Tourism
Yellow Pages Matrimony
Personalities Section News
<% conn.close(); } catch (SQLException E) { out.println("SQLException: " + E.getMessage()); out.println("SQLState: " + E.getSQLState()); out.println("VendorError: " + E.getErrorCode()); } %>