JSP: Se connecter à une base données pour la lecture

Author:
       
<%@ page import="java.sql.*" %>

<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>


    
        Lecture des tables de JDBC 
    

    
        

The tableName Database Table 

        <%              Connection connection = DriverManager.getConnection(                 "jdbc:odbc:data", "Steve", "password");             Statement statement = connection.createStatement() ;             ResultSet resultset =                  statement.executeQuery("select * from tableName") ;          %>                                       ID                 Name                 City                 State                 Country                          <% while(resultset.next()){ %>                               <%= resultset.getString(1) %>                  <%= resultset.getString(2) %>                  <%= resultset.getString(3) %>                  <%= resultset.getString(4) %>                  <%= resultset.getString(5) %>                          <% } %>                                  

A Voir sur le même Sujet:

  • exemple code java

Leave a Reply

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