JSP Java

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

    
        Filling a Table
    
    
        

Filling a Table


        <%  
            Connection connection = null;
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            connection = DriverManager.getConnection("jdbc:odbc:data", "userName", "password");
            Statement statement = connection.createStatement();
            String command = "INSERT INTO Employees (ID, Name) VALUES (1, 'Joe')";
            statement.executeUpdate(command);
            command = "INSERT INTO Employees (ID, Name) VALUES (2, 'Yin')";
            statement.executeUpdate(command);
            ResultSet resultset = 
                statement.executeQuery("select * from Employees");
            while(resultset.next()){ 
        %>
            
                
                    ID
                    Name
                
                
                     <%= resultset.getString(1) %> 
                     <%= resultset.getString(2) %> 
                
            
        <% 
            } 
        %>