2017-08-08 8 views

答えて

1

これは非常にばかげた質問ですが、あなたが質問したので、私はここで答えを書いています。

JDBCを使用してデータベースからデータをフェッチし、レスポンスプリントライタを使用して表示できます。

サンプルプログラム

Connection con; 
PrintWriter out = response.getWriter(); 
response.setContentType("text/html"); 
con = DriverManager.getConnection("jdbc:mysql://localhost:" + "3306" + "/" + "pinnnacledb1", "root", ""); 
String query = "Select * from table where something = ?"; 
PreparedStatement pst = currentCon.prepareStatement(query); 
pst.setString(1, username); 
ResultSet rs = pst.executeQuery(); 
while (rs.next()) 
{ 
    //Your logic for display 
    out.println(<html>Whole html logic can be written here</html>); 

} 

だから今、サーブレットを実行し、その結果をブラウザ上に表示されます。

関連する問題