Hi try the following(do read the last paart on the post)
-
Connection myconn;
-
String DbDriver = "org.gjt.mm.mysql.Driver";
-
String DbConStr = "jdbc:mysql://localhost:3306/xyz";
-
String DbUser ="root";
-
String DbPwd ="abcdef";
-
try {
-
Class.forName(DbDriver);
-
myconn = DriverManager.getConnection(DbConStr, DbUser,DbPwd);
-
Statement mystat = myconn.createStatement();
-
ResultSet rs = mystat.executeQuery("select title,link from sidebar");
-
while (rs.next()) {%>
-
-
-
-
<%
-
String s1= rs.getString(1);
-
String s2= rs.getString(2);
-
out.println(s1);
-
out.println(s2);
-
%>
-
catch(Exception e)
-
{
-
out.println("exception");
-
}
-
****************************************
here the database I used is Mysql
"xyz" is the name of the database
"abcdef" is the password
"root: is the user name..
try this out and tell me the result...
make sure to type the following in the starting of the code
-
<%@ page import =
-
"java.sql.Connection,java.sql.DriverManager,java.sql.SQLException, java.sql.Statement, java.sql.ResultSet, java.util.*,java.io.*"
-
%>
-
Shashank(buz.................ZZZZZZZZZZZZZZZZ..... ...)