altanai bisht

Greenhorn
+ Follow
since Aug 20, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by altanai bisht

correction : it should be

String buttonval= request.getParameter("submit");

in the servlet
11 years ago
here's one way to do it using swings ( works even though deprecated )

Class.forName("org.postgresql.Driver");
System.out.println("driver class found");
conn = DriverManager.getConnection(ur, username, password);
System.out.println("connection "+ conn);

PreparedStatement ps = conn.prepareStatement("SELECT * FROM tablename");
ResultSet rs = ps.executeQuery();
if (rs != null) {
while(rs.next()) {
String name = rs.getString(1);
System.out.println(name);

InputStream is = rs.getBinaryStream(2);
System.out.println(is);
final Image img= ImageIO.read(is);
System.out.println(img);

JFrame frame = new JFrame("Image");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(img.getWidth(frame), img.getHeight(frame));
frame.add(new JPanel() {
public void paint(Graphics g) {
g.drawImage(img, 0, 0, null);
}
});
//frame.show();
frame.setVisible(true);

}
rs.close();
}
ps.close();
11 years ago
JSP