JSP JDBC: Joindre deux tables et afficher le résultat

Author:
       

<%@ page import="java.sql.*" %>
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>


    
        JDBC JSP
    

    
        

Accès Base de données avec JSP

        <%              Connection connection = DriverManager.getConnection(                 "jdbc:odbc:data", "username", "password");             Statement statement = connection.createStatement();             String query = "SELECT a.fname, a.lname, book, titleuthor.id " +               "FROM authors JOIN titleauthor ON authors.id = titleauthor.id";             ResultSet resultset =                  statement.executeQuery(query) ;          %>                                       Nom                 Prénom                 Livre                          <% while(resultset.next()){ %>                               <%= resultset.getString(1) %>                  <%= resultset.getString(2) %>                  <%= resultset.getString(3) %>                          <% } %>                                  

Leave a Reply

Your email address will not be published. Required fields are marked *