<html><body>
<%@ page import="java.sql.*" %>
<%
String user="root@localhost"; // root itself
String password="pwdl";
String connectionURL = "jdbc:mysql://localhost/Database_name";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, user, password);
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * table");
while (rs.next())
{
out.println(rs.getString("name")+"<br>"+rs.
getString("emailid")+"<br>"+rs.getString("contents
")+"<br>");
}
rs.close();
%>
</body></html>
Rajesh.D.N
0
Newbie Poster
Recommended Answers
Jump to Post1) This code should not be in a scriptlet. Move the query part out to a bean.
2) Use a connection pool, or open the connection in a session object (although this type of persistence is frowned upon) because opening a connection for every page load is extremely inefficient.
…
Jump to PostThe actual error message and stacktrace would help. The status 500 message simply tells you something went wrong, not what. Look in the logs for your application for the actuall error (not that I think it's going to help). If you didn't understand what I said, then you have a …
All 5 Replies
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
Rajesh.D.N
0
Newbie Poster
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
lookof2day
6
Junior Poster in Training
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
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.